Zelda Classic Coverage Report


Directory: src/
File: src/zc/ffscript.cpp
Date: 2023-10-22 07:04:23
Exec Total Coverage
Lines: 5383 27442 19.6%
Functions: 307 1070 28.7%
Branches: 3183 21477 14.8%

Line Branch Exec Source
1 #include <deque>
2 #include <string>
3 #include <sstream>
4 #include <math.h>
5 #include <cstdio>
6 //
7 #include <sys/types.h>
8 #include <sys/stat.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <fstream>
12 #include <filesystem>
13 #include <fmt/format.h>
14 //
15
16 #include "base/qrs.h"
17 #include "base/dmap.h"
18 #include "base/msgstr.h"
19 #include "base/packfile.h"
20 #include "base/misctypes.h"
21 #include "base/initdata.h"
22 #include "zc/zc_sys.h"
23 #include "zc/jit.h"
24 #include "zc/script_debug.h"
25 #include "base/zc_alleg.h"
26 #include "base/zc_math.h"
27 #include "base/zc_array.h"
28 #include "zc/ffscript.h"
29 #include "zc/render.h"
30 #include "zc/zc_subscr.h"
31 #include <time.h>
32 #include "zc/script_drawing.h"
33 #include "base/util.h"
34 #include "zc/ending.h"
35 #include "base/module.h"
36 #include "zc/combos.h"
37 #include "drawing.h"
38 #include "base/colors.h"
39 #include "pal.h"
40 #include "zinfo.h"
41 #include "subscr.h"
42 #include "zc_list_data.h"
43 #include <sstream>
44
45 #ifdef _WIN32
46 #define SCRIPT_FILE_MODE (_S_IREAD | _S_IWRITE)
47 #else
48 #include <fcntl.h>
49 #include <unistd.h>
50 #include <iostream>
51 #define SCRIPT_FILE_MODE (S_ISVTX | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
52 #endif
53
54 //Define this register, so it can be treated specially
55 #define NUL 5
56 #define MAX_ZC_ARRAY_SIZE 214748
57
58 // #define _SCRIPT_COUNTER
59
60 #ifdef _SCRIPT_COUNTER
61 static int64_t script_timer[NUMCOMMANDS];
62 static int64_t script_execount[NUMCOMMANDS];
63 #endif
64
65 using namespace util;
66 using std::ostringstream;
67
68 extern byte use_dwm_flush;
69 uint8_t using_SRAM = 0;
70
71 int32_t hangcount = 0;
72 bool can_neg_array = true;
73
74 116 extern byte monochrome_console;
75
76 116 static std::set<int> seen_scripts;
77 116 static std::map<int, ScriptDebugHandle> script_debug_handles;
78 ScriptDebugHandle* runtime_script_debug_handle;
79 116 static std::map<std::pair<script_data*, refInfo*>, JittedScriptHandle*> jitted_scripts;
80 int32_t jitted_uncompiled_command_count;
81
82 116 CScriptDrawingCommands scriptdraws;
83 116 FFScript FFCore;
84 ZModule zcm;
85 zcmodule moduledata;
86 116 script_bitmaps scb;
87
3/4
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29580 times.
✓ Branch 3 taken 116 times.
29696 user_file script_files[MAX_USER_FILES];
88
3/4
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29580 times.
✓ Branch 3 taken 116 times.
29696 user_dir script_dirs[MAX_USER_DIRS];
89
3/4
✓ Branch 0 taken 24910768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24910652 times.
✓ Branch 3 taken 116 times.
24910768 user_object script_objects[MAX_USER_OBJECTS];
90
3/4
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29580 times.
✓ Branch 3 taken 116 times.
29696 user_stack script_stacks[MAX_USER_STACKS];
91 116 user_rng nulrng;
92 116 user_rng script_rngs[MAX_USER_RNGS];
93 116 zc_randgen script_rnggens[MAX_USER_RNGS];
94 116 user_paldata script_paldatas[MAX_USER_PALDATAS];
95
96 FONT *get_zc_font(int index);
97
98 int32_t combopos_modified = -1;
99 static word combo_id_cache[7*176] = {0};
100
101 58112 void user_dir::clear()
102 {
103 58112 user_abstract_obj::clear();
104 58112 filepath = "";
105 58112 reserved = false;
106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58112 times.
58112 if(list)
107 {
108 list->clear();
109 free(list);
110 list = NULL;
111 }
112 58112 }
113 void user_dir::setPath(const char* buf)
114 {
115 if(!list)
116 {
117 list = (FLIST *) malloc(sizeof(FLIST));
118 }
119 reserved = true;
120 filepath = std::string(buf) + "/";
121 regulate_path(filepath);
122 list->load(filepath.c_str());
123 }
124
125 int32_t CScriptDrawingCommands::GetCount()
126 {
127 al_trace("current number of draws is: %d\n", count);
128 return count;
129 }
130 //Advances the game frame without checking 'Quit' variable status.
131 //Used for making scripts such as Player's onWin and onDeath scripts
132 //run for multiple frames.
133
134 void FFScript::Waitframe(bool allowwavy, bool sfxcleanup)
135 {
136 if(zcmusic!=NULL)
137 {
138 zcmusic_poll();
139 }
140 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
141
142 while(Paused && !Advance && !Quit)
143 {
144 // have to call this, otherwise we'll get an infinite loop
145 syskeys();
146 // to keep fps constant
147 updatescr(allowwavy);
148 zc_throttle_fps();
149
150 #ifdef _WIN32
151
152 if(use_dwm_flush)
153 {
154 do_DwmFlush();
155 }
156
157 #endif
158
159 // to keep music playing
160 if(zcmusic!=NULL)
161 {
162 zcmusic_poll();
163 }
164 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
165
166 update_hw_screen();
167 }
168
169 //if(Quit)
170 // return;
171 /*
172 if(Playing && game->get_time()<MAXTIME)
173 game->change_time(1);
174 */
175 Advance=false;
176 ++frame;
177
178 syskeys();
179 // Someday... maybe install a Turbo button here?
180 updatescr(allowwavy);
181 zc_throttle_fps();
182
183 #ifdef _WIN32
184
185 if(use_dwm_flush)
186 {
187 do_DwmFlush();
188 }
189
190 #endif
191
192 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
193 if(sfxcleanup)
194 sfx_cleanup();
195 }
196
197 18561592 mapscr* GetMapscr(int32_t mapref)
198 {
199
6/15
✓ Branch 0 taken 30619 times.
✓ Branch 1 taken 17428017 times.
✓ Branch 2 taken 135370 times.
✓ Branch 3 taken 16181 times.
✓ Branch 4 taken 1957 times.
✓ Branch 5 taken 949448 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
18561592 switch(mapref)
200 {
201 30619 case MAPSCR_TEMP0: return FFCore.tempScreens[0]; //Temp layer 0
202 135370 case MAPSCR_TEMP1: return FFCore.tempScreens[1]; //Temp layer 1
203 16181 case MAPSCR_TEMP2: return FFCore.tempScreens[2]; //Temp layer 2
204 1957 case MAPSCR_TEMP3: return FFCore.tempScreens[3]; //Temp layer 3
205 949448 case MAPSCR_TEMP4: return FFCore.tempScreens[4]; //Temp layer 4
206 case MAPSCR_TEMP5: return FFCore.tempScreens[5]; //Temp layer 5
207 case MAPSCR_TEMP6: return FFCore.tempScreens[6]; //Temp layer 6
208 case MAPSCR_SCROLL0: return FFCore.ScrollingScreens[0]; //Temp scrolllayer 0
209 case MAPSCR_SCROLL1: return FFCore.ScrollingScreens[1]; //Temp scrolllayer 1
210 case MAPSCR_SCROLL2: return FFCore.ScrollingScreens[2]; //Temp scrolllayer 2
211 case MAPSCR_SCROLL3: return FFCore.ScrollingScreens[3]; //Temp scrolllayer 3
212 case MAPSCR_SCROLL4: return FFCore.ScrollingScreens[4]; //Temp scrolllayer 4
213 case MAPSCR_SCROLL5: return FFCore.ScrollingScreens[5]; //Temp scrolllayer 5
214 case MAPSCR_SCROLL6: return FFCore.ScrollingScreens[6]; //Temp scrolllayer 6
215 default:
216 {
217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17428017 times.
17428017 if(mapref < 0) return NULL; //Bad negative value
218 17428017 else return &TheMaps[mapref]; //Standard mapdata
219 }
220 }
221 18561592 }
222
223 18 int32_t getMap(int32_t ref)
224 {
225
1/15
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
18 switch(ref)
226 {
227 case MAPSCR_TEMP0:
228 return currmap+1;
229 case MAPSCR_TEMP1:
230 return FFCore.tempScreens[0]->layermap[0];
231 case MAPSCR_TEMP2:
232 return FFCore.tempScreens[0]->layermap[1];
233 case MAPSCR_TEMP3:
234 return FFCore.tempScreens[0]->layermap[2];
235 case MAPSCR_TEMP4:
236 return FFCore.tempScreens[0]->layermap[3];
237 case MAPSCR_TEMP5:
238 return FFCore.tempScreens[0]->layermap[4];
239 case MAPSCR_TEMP6:
240 return FFCore.tempScreens[0]->layermap[5];
241 case MAPSCR_SCROLL0:
242 return scrolling_map+1;
243 case MAPSCR_SCROLL1:
244 return FFCore.ScrollingScreens[0]->layermap[0];
245 case MAPSCR_SCROLL2:
246 return FFCore.ScrollingScreens[0]->layermap[1];
247 case MAPSCR_SCROLL3:
248 return FFCore.ScrollingScreens[0]->layermap[2];
249 case MAPSCR_SCROLL4:
250 return FFCore.ScrollingScreens[0]->layermap[3];
251 case MAPSCR_SCROLL5:
252 return FFCore.ScrollingScreens[0]->layermap[4];
253 case MAPSCR_SCROLL6:
254 return FFCore.ScrollingScreens[0]->layermap[5];
255 default:
256 18 return (ref / MAPSCRS + 1);
257 }
258 18 }
259 42 int32_t getScreen(int32_t ref)
260 {
261
1/15
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
42 switch(ref)
262 {
263 case MAPSCR_TEMP0:
264 return currscr;
265 case MAPSCR_TEMP1:
266 return FFCore.tempScreens[0]->layerscreen[0];
267 case MAPSCR_TEMP2:
268 return FFCore.tempScreens[0]->layerscreen[1];
269 case MAPSCR_TEMP3:
270 return FFCore.tempScreens[0]->layerscreen[2];
271 case MAPSCR_TEMP4:
272 return FFCore.tempScreens[0]->layerscreen[3];
273 case MAPSCR_TEMP5:
274 return FFCore.tempScreens[0]->layerscreen[4];
275 case MAPSCR_TEMP6:
276 return FFCore.tempScreens[0]->layerscreen[5];
277 case MAPSCR_SCROLL0:
278 return scrolling_scr;
279 case MAPSCR_SCROLL1:
280 return FFCore.ScrollingScreens[0]->layerscreen[0];
281 case MAPSCR_SCROLL2:
282 return FFCore.ScrollingScreens[0]->layerscreen[1];
283 case MAPSCR_SCROLL3:
284 return FFCore.ScrollingScreens[0]->layerscreen[2];
285 case MAPSCR_SCROLL4:
286 return FFCore.ScrollingScreens[0]->layerscreen[3];
287 case MAPSCR_SCROLL5:
288 return FFCore.ScrollingScreens[0]->layerscreen[4];
289 case MAPSCR_SCROLL6:
290 return FFCore.ScrollingScreens[0]->layerscreen[5];
291 default:
292 42 return (ref % MAPSCRS);
293 }
294 42 }
295
296 dword get_subref(int sub, byte ty, byte pg = 0, word ind = 0)
297 {
298 byte s;
299 if(sub == -1) //special; load current
300 {
301 s = new_sub_indexes[ty];
302 if(s < 0) return 0;
303 }
304 else if(unsigned(sub) < 256)
305 s = sub;
306 else return 0;
307 ++ty; //type is offset by 1
308 return (s<<24)|(pg<<16)|((ty&0x7)<<13)|(ind&0x1FFF);
309 }
310 std::tuple<byte,int8_t,byte,word> from_subref(dword ref)
311 {
312 byte type = (ref>>13)&0x07;
313 if(!type)
314 return { 0, -1, 0, 0 };
315
316 byte sub = (ref>>24)&0xFF;
317 byte pg = (ref>>16)&0xFF;
318 word ind = (ref)&0x1FFF;
319 return { sub, type-1, pg, ind };
320 }
321
322 std::tuple<ZCSubscreen*,SubscrPage*,SubscrWidget*,byte> load_subscreen_ref(dword ref)
323 {
324 auto [sub,ty,pg,ind] = from_subref(ref);
325 ZCSubscreen* sbscr = nullptr;
326 SubscrPage* sbpg = nullptr;
327 SubscrWidget* sbwidg = nullptr;
328 switch(ty)
329 {
330 case sstACTIVE:
331 if(sub < subscreens_active.size())
332 sbscr = &subscreens_active[sub];
333 break;
334 case sstPASSIVE:
335 if(sub < subscreens_passive.size())
336 sbscr = &subscreens_passive[sub];
337 break;
338 case sstOVERLAY:
339 if(sub < subscreens_overlay.size())
340 sbscr = &subscreens_overlay[sub];
341 break;
342 }
343 if(sbscr)
344 {
345 if(pg < sbscr->pages.size())
346 sbpg = &sbscr->pages[pg];
347 }
348 else return { nullptr, nullptr, nullptr, -1 }; //no subscreen
349 if(sbpg)
350 {
351 if(ind < sbpg->size())
352 sbwidg = sbpg->at(ind);
353 }
354 return { sbscr, sbpg, sbwidg, ty };
355 }
356 std::pair<ZCSubscreen*,byte> load_subdata(dword ref)
357 {
358 auto [sub,_pg,_widg,ty] = load_subscreen_ref(ref);
359 return { sub, ty };
360 }
361 std::pair<SubscrPage*,byte> load_subpage(dword ref)
362 {
363 auto [_sub,pg,_widg,ty] = load_subscreen_ref(ref);
364 return { pg, ty };
365 }
366 std::pair<SubscrWidget*,byte> load_subwidg(dword ref)
367 {
368 auto [_sub,_pg,widg,ty] = load_subscreen_ref(ref);
369 return { widg, ty };
370 }
371
372 #include "zconsole/ConsoleLogger.h"
373
374 //no ifdef here
375 116 CConsoleLoggerEx coloured_console;
376 extern CConsoleLoggerEx zscript_coloured_console;
377
378 int32_t FFScript::UpperToLower(std::string *s)
379 {
380 if ( s->size() < 1 )
381 {
382 Z_scripterrlog("String passed to UpperToLower() is too small. Size is: %d \n", s->size());
383 return 0;
384 }
385 for ( size_t q = 0; q < s->size(); ++q )
386 {
387 //if ( s->at(q) >= 'A' || s->at(q) <= 'Z' )
388 //{
389 // s->at(q) += 32;
390 //}
391 s->at(q) += 32 * (s->at(q) >= 'A' && s->at(q) <= 'Z');
392 }
393 return 1;
394 }
395
396 int32_t FFScript::LowerToUpper(std::string *s)
397 {
398 if ( s->size() < 1 )
399 {
400 Z_scripterrlog("String passed to LowerToUpper() is too small. Size is: %d \n", s->size());
401 return 0;
402 }
403 for ( size_t q = 0; q < s->size(); ++q )
404 {
405 //if ( s->at(q) >= 'a' || s->at(q) <= 'z' )
406 //{
407 // s->at(q) -= 32;
408 //}
409 s->at(q) -= 32 * (s->at(q) >= 'a' && s->at(q) <= 'z');
410 }
411 return 1;
412 }
413
414 int32_t FFScript::ConvertCase(std::string *s)
415 {
416 if ( s->size() < 1 )
417 {
418 Z_scripterrlog("String passed to UpperToLower() is too small. Size is: %d \n", s->size());
419 return 0;
420 }
421 for ( size_t q = 0; q < s->size(); ++q )
422 {
423 if ( s->at(q) >= 'a' || s->at(q) <= 'z' )
424 {
425 s->at(q) -= 32;
426 }
427 else if ( s->at(q) >= 'A' || s->at(q) <= 'Z' )
428 {
429 s->at(q) += 32;
430 }
431 }
432 zprint("FFScript::ConvertCase(std::string s), post-conversion, string is: %s\n", s->c_str());
433 return 1;
434 }
435
436 bool FFScript::isNumber(char chr)
437 {
438 if ( chr >= '0' )
439 {
440 if ( chr <= '9' ) return true;
441 }
442 return false;
443 }
444
445 int32_t FFScript::ilen(char *p)
446 {
447 int32_t ret = 0; int32_t pos = 0;
448 if(p[pos] == '-')
449 ret++;
450 for(; FFCore.isNumber(p[pos + ret]); ++ret);
451 return ret;
452 }
453
454 int32_t FFScript::zc_strlen(char *p)
455 {
456 int32_t count = 0;
457
458 while(*p!='\0')
459 {
460 count++;
461 p++;
462 }
463
464 return count;
465 }
466
467 int32_t FFScript::atox(char *ip_str)
468 {
469 char tmp[2]={'2','\0'};
470 int32_t op_val=0, i=0, ip_len = FFCore.zc_strlen(ip_str);
471
472 if(strncmp(ip_str, "0x", 2) == 0)
473 {
474 ip_str +=2;
475 ip_len -=2;
476 }
477
478 for(i=0;i<ip_len;i++)
479 {
480 op_val *= 0x10;
481 switch(ip_str[i])
482 {
483 case 'a':
484 op_val += 0xa;
485 break;
486 case 'b':
487 op_val += 0xb;
488 break;
489 case 'c':
490 op_val += 0xc;
491 break;
492 case 'd':
493 op_val += 0xd;
494 break;
495 case 'e':
496 op_val += 0xe;
497 break;
498 case 'f':
499 op_val += 0xf;
500 break;
501 case '0':
502 case '1':
503 case '2':
504 case '3':
505 case '4':
506 case '5':
507 case '6':
508 case '7':
509 case '8':
510 case '9':
511 tmp[0] = ip_str[i];
512 op_val += atoi(tmp);
513 break;
514 default :
515 op_val += 0x0;
516 break;
517 }
518 }
519 return op_val;
520 }
521
522 char runningItemScripts[256] = {0};
523
524 //item *FFCore.temp_ff_item = NULL;
525 //enemy *FFCore.temp_ff_enemy = NULL;
526 //weapon *FFCore.temp_ff_lweapon = NULL;
527 //weapon *FFCore.temp_ff_eweapon = NULL;
528
529 #include "zc/zelda.h"
530 #include "particles.h"
531 #include "zc/hero.h"
532 extern int32_t directItemA;
533 extern int32_t directItemB;
534 extern int32_t directItemX;
535 extern int32_t directItemY;
536
537 #include "zc/guys.h"
538 #include "gamedata.h"
539 #include "zc/zc_init.h"
540 #include "base/zsys.h"
541 #include "base/misctypes.h"
542 #include "zc/title.h"
543 #include "zscriptversion.h"
544
545 #include "pal.h"
546 #include "base/zdefs.h"
547 #include "zc/rendertarget.h"
548
549 #include "zc/zc_custom.h"
550 #include "qst.h"
551
552 #ifdef _MSC_VER
553 #pragma warning ( disable : 4800 ) //int32_t to bool town. population: lots.
554 #endif
555
556 #define NUMSHOPS 256
557 #define NUMINFOSHOPS 511
558
559 //! New datatype vars for 2.54:
560
561 //spritedata sp->member
562
563
564 using std::string;
565
566 extern particle_list particles;
567 extern HeroClass Hero;
568 extern char *guy_string[];
569 extern int32_t skipcont;
570
571 PALETTE tempgreypal; //Palettes go here. This is used for Greyscale() / Monochrome()
572 PALETTE userPALETTE[256]; //Palettes go here. This is used for Greyscale() / Monochrome()
573 PALETTE tempblackpal; //Used for storing the palette while fading to black
574
575 116 FFScript ffengine;
576
577 byte FF_hero_action; //This way, we can make safe replicas of internal Hero actions to be set by script.
578
579 int32_t FF_screenbounds[4]; //edges of the screen, left, right, top, bottom used for where to scroll.
580 int32_t FF_screen_dimensions[4]; //height, width, displaywidth, displayheight
581 int32_t FF_subscreen_dimensions[4];
582 int32_t FF_eweapon_removal_bounds[4]; //left, right, top, bottom coordinates for automatic eweapon removal.
583 int32_t FF_lweapon_removal_bounds[4]; //left, right, top, bottom coordinates for automatic lweapon removal.
584 int32_t FF_clocks[FFSCRIPTCLASS_CLOCKS]; //Will be used for Heroaction, anims, and so forth
585 byte ScriptDrawingRules[SCRIPT_DRAWING_RULES];
586 int32_t FF_UserMidis[NUM_USER_MIDI_OVERRIDES]; //MIDIs to use for Game Over, and similar to override system defaults.
587
588 int32_t get_int_arr(const int32_t ptr, int32_t indx);
589 void set_int_arr(const int32_t ptr, int32_t indx, int32_t val);
590 int32_t sz_int_arr(const int32_t ptr);
591
592 //We gain some speed by not passing as arguments
593 int32_t sarg1 = 0;
594 int32_t sarg2 = 0;
595 std::vector<int32_t> *sargvec;
596 std::string *sargstr;
597 refInfo *ri = NULL;
598 script_data *curscript = NULL;
599 int32_t(*stack)[MAX_SCRIPT_REGISTERS] = NULL;
600 std::vector<int32_t> zs_vargs;
601 ScriptType curScriptType;
602 word curScriptNum;
603 int32_t curScriptIndex;
604 bool script_funcrun = false;
605 std::string* destructstr = nullptr;
606
607 static std::vector<ScriptType> curScriptType_cache;
608 static std::vector<int32_t> curScriptNum_cache;
609 static std::vector<int32_t> curScriptIndex_cache;
610 static std::vector<int32_t> sarg1cache;
611 static std::vector<int32_t> sarg2cache;
612 static std::vector<std::vector<int32_t>*> sargvec_cache;
613 static std::vector<std::string*> sargstr_cache;
614 static std::vector<refInfo*> ricache;
615 static std::vector<script_data*> sdcache;
616 static std::vector<int32_t(*)[MAX_SCRIPT_REGISTERS]> stackcache;
617 10 void push_ri()
618 {
619 10 sarg1cache.push_back(sarg1);
620 10 sarg2cache.push_back(sarg2);
621 10 curScriptType_cache.push_back(curScriptType);
622 10 curScriptNum_cache.push_back(curScriptNum);
623 10 curScriptIndex_cache.push_back(curScriptIndex);
624 10 sargvec_cache.push_back(sargvec);
625 10 sargstr_cache.push_back(sargstr);
626 10 ricache.push_back(ri);
627 10 sdcache.push_back(curscript);
628 10 stackcache.push_back(stack);
629 10 }
630 10 void pop_ri()
631 {
632 10 sarg1 = sarg1cache.back(); sarg1cache.pop_back();
633 10 sarg2 = sarg2cache.back(); sarg2cache.pop_back();
634 10 curScriptType = curScriptType_cache.back(); curScriptType_cache.pop_back();
635 10 curScriptNum = curScriptNum_cache.back(); curScriptNum_cache.pop_back();
636 10 curScriptIndex = curScriptIndex_cache.back(); curScriptIndex_cache.pop_back();
637 10 sargvec = sargvec_cache.back(); sargvec_cache.pop_back();
638 10 sargstr = sargstr_cache.back(); sargstr_cache.pop_back();
639 10 ri = ricache.back(); ricache.pop_back();
640 10 curscript = sdcache.back(); sdcache.pop_back();
641 10 stack = stackcache.back(); stackcache.pop_back();
642 10 }
643
644 static int32_t numInstructions = 0; // Used to detect hangs
645 static bool scriptCanSave = true;
646
647 std::vector<refInfo*> genericActiveData;
648 std::vector<int32_t(*)[MAX_SCRIPT_REGISTERS]> generic_active_stack;
649 bool gen_active_doscript = false, gen_active_initialized = false;
650
651 285908 struct ScriptEngineData {
652 refInfo ref;
653 int32_t stack[MAX_SCRIPT_REGISTERS];
654 // This is used as a boolean for all but ScriptType::Item.
655 285908 byte doscript = true;
656 bool waitdraw;
657 bool initialized;
658
659 2576643 void reset()
660 {
661 // No need to zero the stack.
662 2576643 ref = refInfo();
663 2576643 doscript = true;
664 2576643 waitdraw = false;
665 2576643 initialized = false;
666 2576643 }
667 };
668
669 // (type, index) => ScriptEngineData
670 116 static std::map<std::pair<ScriptType, word>, ScriptEngineData> scriptEngineDatas;
671
672 349545496 static ScriptEngineData& get_script_engine_data(ScriptType type, int index)
673 {
674
8/8
✓ Branch 0 taken 333253905 times.
✓ Branch 1 taken 16291591 times.
✓ Branch 2 taken 333253788 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 316976222 times.
✓ Branch 5 taken 16277566 times.
✓ Branch 6 taken 17757 times.
✓ Branch 7 taken 316958465 times.
349545496 if (type == ScriptType::DMap || type == ScriptType::OnMap || type == ScriptType::ScriptedPassiveSubscreen || type == ScriptType::ScriptedActiveSubscreen)
675 {
676 // `index` is used for dmapref, not for different script engine data.
677 32587031 index = 0;
678 32587031 }
679
1/2
✓ Branch 0 taken 349545496 times.
✗ Branch 1 not taken.
349545496 if (type == ScriptType::EngineSubscreen)
680 {
681 // `index` is used for subdataref, not for different script engine data.
682 index = 0;
683 }
684
685 349545496 return scriptEngineDatas[{type, index}];
686 }
687
688 44 static ScriptEngineData& get_script_engine_data(ScriptType type)
689 {
690 44 return scriptEngineDatas[{type, 0}];
691 }
692
693 409 void FFScript::clear_script_engine_data()
694 {
695 409 scriptEngineDatas.clear();
696 409 }
697
698 2112259 void FFScript::reset_script_engine_data(ScriptType type, int index)
699 {
700 2112259 get_script_engine_data(type, index).reset();
701 2112259 }
702
703 164089 void FFScript::clear_script_engine_data(ScriptType type, int index)
704 {
705
4/8
✓ Branch 0 taken 164089 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 164089 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 164089 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 164089 times.
164089 if (type == ScriptType::DMap || type == ScriptType::OnMap || type == ScriptType::ScriptedPassiveSubscreen || type == ScriptType::ScriptedActiveSubscreen)
706 {
707 // `index` is used for dmapref, not for different script engine data.
708 index = 0;
709 }
710
1/2
✓ Branch 0 taken 164089 times.
✗ Branch 1 not taken.
164089 if (type == ScriptType::EngineSubscreen)
711 {
712 // `index` is used for subdataref, not for different script engine data.
713 index = 0;
714 }
715
716 164089 auto it = scriptEngineDatas.find({type, index});
717
2/2
✓ Branch 0 taken 164037 times.
✓ Branch 1 taken 52 times.
164089 if (it != scriptEngineDatas.end())
718 {
719 52 scriptEngineDatas.erase(it);
720 52 }
721 164089 }
722
723 58864 void FFScript::clear_script_engine_data_of_type(ScriptType type)
724 {
725 38038123 std::erase_if(scriptEngineDatas, [&](auto& kv) { return kv.first.first == type; });
726 58864 }
727
728 194 refInfo& FFScript::ref(ScriptType type, int index)
729 {
730 194 return get_script_engine_data(type, index).ref;
731 }
732
733 32458782 byte& FFScript::doscript(ScriptType type, int index)
734 {
735 32458782 return get_script_engine_data(type, index).doscript;
736 }
737
738 267139824 bool& FFScript::waitdraw(ScriptType type, int index)
739 {
740 267139824 return get_script_engine_data(type, index).waitdraw;
741 }
742
743 // Returns true if registers had to be initialized.
744 8923341 static bool set_current_script_engine_data(ScriptType type, int script, int index)
745 {
746 8923341 bool got_initialized = false;
747
748 8923341 auto& data = get_script_engine_data(type, index);
749 8923341 ri = &data.ref;
750 8923341 stack = &data.stack;
751
752
10/12
✓ Branch 0 taken 271331 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38089 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4682741 times.
✓ Branch 5 taken 4287 times.
✓ Branch 6 taken 3889476 times.
✓ Branch 7 taken 13747 times.
✓ Branch 8 taken 114 times.
✓ Branch 9 taken 12244 times.
✓ Branch 10 taken 1402 times.
✓ Branch 11 taken 9910 times.
8923341 switch (type)
753 {
754 case ScriptType::FFC:
755 {
756 4682741 curscript = ffscripts[script];
757
758
2/2
✓ Branch 0 taken 4667083 times.
✓ Branch 1 taken 15658 times.
4682741 if (!data.initialized)
759 {
760 15658 got_initialized = true;
761 15658 memcpy(ri->d, tmpscr->ffcs[index].initd, 8 * sizeof(int32_t));
762 15658 memcpy(ri->a, tmpscr->ffcs[index].inita, 2 * sizeof(int32_t));
763 15658 data.initialized = true;
764 15658 }
765
766 4682741 ri->ffcref = index;
767 }
768 4682741 break;
769
770 // case ScriptType::NPC:
771 // {
772 // int32_t npc_index = GuyH::getNPCIndex(i);
773 // enemy *w = (enemy*)guys.spr(npc_index);
774 // ri = &(w->scrmem->scriptData);
775 // curscript = guyscripts[w->script];
776 // stack = &(w->scrmem->stack);
777 // ri->guyref = i;
778
779 // if (!w->initialised)
780 // {
781 // got_initialized = true;
782 // for ( int32_t q = 0; q < 8; q++ )
783 // {
784 // ri->d[q] = w->initD[q];
785 // }
786 // w->initialised = 1;
787 // }
788 // }
789 // break;
790
791 // case ScriptType::Lwpn:
792 // {
793 // int32_t lwpn_index = LwpnH::getLWeaponIndex(i);
794 // weapon *w = (weapon*)Lwpns.spr(lwpn_index);
795 // ri = &(w->scrmem->scriptData);
796 // curscript = lwpnscripts[w->weaponscript];
797 // stack = &(w->scrmem->stack);
798 // ri->lwpn = i;
799
800 // if (!w->initialised)
801 // {
802 // got_initialized = true;
803 // for ( int32_t q = 0; q < 8; q++ )
804 // {
805 // ri->d[q] = w->weap_initd[q]; //w->initiald[q];
806 // }
807 // w->initialised = 1;
808 // }
809 // }
810 // break;
811
812 // case ScriptType::Ewpn:
813 // {
814 // int32_t ewpn_index = EwpnH::getEWeaponIndex(i);
815 // weapon *w = (weapon*)Ewpns.spr(ewpn_index);
816 // ri = &(w->scrmem->scriptData);
817 // curscript = ewpnscripts[w->weaponscript];
818 // stack = &(w->scrmem->stack);
819 // ri->ewpn = i;
820
821 // if (!w->initialised)
822 // {
823 // got_initialized = true;
824 // for ( int32_t q = 0; q < 8; q++ )
825 // {
826 // ri->d[q] = w->weap_initd[q];
827 // }
828 // w->initialised = 1;
829 // }
830 // }
831 // break;
832
833 // case ScriptType::ItemSprite:
834 // {
835 // int32_t the_index = ItemH::getItemIndex(i);
836 // item *w = (item*)items.spr(the_index);
837 // ri = &(w->scrmem->scriptData);
838 // curscript = itemspritescripts[w->script];
839 // stack = &(w->scrmem->stack);
840 // ri->itemref = i;
841
842 // if (!w->initialised)
843 // {
844 // got_initialized = true;
845 // for ( int32_t q = 0; q < 8; q++ )
846 // {
847 // ri->d[q] = w->initD[q];
848 // }
849 // w->initialised = 1;
850 // }
851 // }
852 // break;
853
854 case ScriptType::Item:
855 {
856 4287 int32_t i = index;
857 4287 int32_t new_i = 0;
858
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 4093 times.
4287 bool collect = ( ( i < 1 ) || (i == COLLECT_SCRIPT_ITEM_ZERO) );
859
3/4
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 4093 times.
✓ Branch 2 taken 194 times.
✗ Branch 3 not taken.
4287 new_i = ( collect ) ? (( i != COLLECT_SCRIPT_ITEM_ZERO ) ? (i * -1) : 0) : i;
860
861 4287 curscript = itemscripts[script];
862
863
2/2
✓ Branch 0 taken 3278 times.
✓ Branch 1 taken 1009 times.
4287 if (!data.initialized)
864 {
865 1009 got_initialized = true;
866
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
1009 memcpy(ri->d, ( collect ) ? itemsbuf[new_i].initiald : itemsbuf[i].initiald, 8 * sizeof(int32_t));
867
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
1009 memcpy(ri->a, ( collect ) ? itemsbuf[new_i].initiala : itemsbuf[i].initiala, 2 * sizeof(int32_t));
868 1009 data.initialized = true;
869 1009 }
870
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 4093 times.
4287 ri->idata = ( collect ) ? new_i : i; //'this' pointer
871 }
872 4287 break;
873
874 case ScriptType::Global:
875 {
876 3889476 curscript = globalscripts[script];
877 }
878 3889476 break;
879
880 // case ScriptType::Generic:
881 // {
882 // user_genscript& scr = user_scripts[script];
883 // stack = &scr.stack;
884 // ri = &scr.ri;
885 // ri->genericdataref = script;
886 // curscript = genericscripts[script];
887 // scr.waitevent = false;
888 // if(!scr.initialized)
889 // {
890 // got_initialized = true;
891 // scr.initialized = true;
892 // memcpy(ri->d, scr.initd, 8 * sizeof(int32_t));
893 // }
894 // }
895 // break;
896
897 // case ScriptType::GenericFrozen:
898 // {
899 // ri = genericActiveData.back();
900 // ri->genericdataref = script;
901 // curscript = genericscripts[script];
902 // stack = generic_active_stack.back();
903 // if(!gen_active_initialized)
904 // {
905 // got_initialized = true;
906 // gen_active_initialized = true;
907 // memcpy(ri->d, user_scripts[script].initd, 8 * sizeof(int32_t));
908 // }
909 // }
910 // break;
911
912 case ScriptType::Player:
913 {
914 271331 curscript = playerscripts[script];
915 }
916 271331 break;
917
918 case ScriptType::DMap:
919 {
920 13747 curscript = dmapscripts[script];
921 13747 ri->dmapsref = index;
922 //how do we clear initialised on dmap change?
923
2/2
✓ Branch 0 taken 13732 times.
✓ Branch 1 taken 15 times.
13747 if ( !data.initialized )
924 {
925 15 got_initialized = true;
926
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 15 times.
135 for ( int32_t q = 0; q < 8; q++ )
927 {
928 120 ri->d[q] = DMaps[ri->dmapsref].initD[q];// * 10000;
929 120 }
930 15 data.initialized = true;
931 15 }
932 }
933 13747 break;
934
935 case ScriptType::OnMap:
936 {
937 114 curscript = dmapscripts[script];
938 114 ri->dmapsref = index;
939
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 3 times.
114 if (!data.initialized)
940 {
941 3 got_initialized = true;
942
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 3 times.
27 for ( int32_t q = 0; q < 8; q++ )
943 {
944 24 ri->d[q] = DMaps[ri->dmapsref].onmap_initD[q];
945 24 }
946 3 data.initialized = true;
947 3 }
948 }
949 114 break;
950
951 case ScriptType::ScriptedActiveSubscreen:
952 {
953 12244 curscript = dmapscripts[script];
954 12244 ri->dmapsref = index;
955
2/2
✓ Branch 0 taken 12203 times.
✓ Branch 1 taken 41 times.
12244 if (!data.initialized)
956 {
957 41 got_initialized = true;
958
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 41 times.
369 for ( int32_t q = 0; q < 8; q++ )
959 {
960 328 ri->d[q] = DMaps[ri->dmapsref].sub_initD[q];
961 328 }
962 41 data.initialized = true;
963 41 }
964 }
965 12244 break;
966
967 case ScriptType::ScriptedPassiveSubscreen:
968 {
969 1402 curscript = dmapscripts[script];
970 1402 ri->dmapsref = index;
971
2/2
✓ Branch 0 taken 1400 times.
✓ Branch 1 taken 2 times.
1402 if (!data.initialized)
972 {
973 2 got_initialized = true;
974
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
18 for ( int32_t q = 0; q < 8; q++ )
975 {
976 16 ri->d[q] = DMaps[ri->dmapsref].sub_initD[q];
977 16 }
978 2 data.initialized = true;
979 2 }
980 }
981 1402 break;
982 case ScriptType::EngineSubscreen:
983 {
984 curscript = subscreenscripts[script];
985 ri->subdataref = get_subref(-1, sstACTIVE);
986 auto [ptr,_ty] = load_subdata(ri->subdataref);
987
988 if (ptr && !data.initialized)
989 {
990 got_initialized = true;
991 for ( int32_t q = 0; q < 8; q++ )
992 {
993 ri->d[q] = ptr->initd[q];
994 }
995 data.initialized = true;
996 }
997 }
998 break;
999
1000 case ScriptType::Screen:
1001 {
1002 9910 curscript = screenscripts[script];
1003
1004
2/2
✓ Branch 0 taken 9887 times.
✓ Branch 1 taken 23 times.
9910 if (!data.initialized)
1005 {
1006 23 got_initialized = true;
1007
2/2
✓ Branch 0 taken 184 times.
✓ Branch 1 taken 23 times.
207 for ( int32_t q = 0; q < 8; q++ )
1008 {
1009 184 ri->d[q] = tmpscr->screeninitd[q];// * 10000;
1010 184 }
1011 23 data.initialized = true;
1012 23 }
1013 }
1014 9910 break;
1015
1016 case ScriptType::Combo:
1017 {
1018 38089 curscript = comboscripts[script];
1019
1020 38089 int32_t pos = combopos_ref_to_pos(index);
1021 38089 int32_t lyr = combopos_ref_to_layer(index);
1022 38089 int32_t id = FFCore.tempScreens[lyr]->data[pos];
1023
2/2
✓ Branch 0 taken 37715 times.
✓ Branch 1 taken 374 times.
38089 if (!data.initialized)
1024 {
1025 374 got_initialized = true;
1026 374 memset(ri->d, 0, 8 * sizeof(int32_t));
1027
2/2
✓ Branch 0 taken 2992 times.
✓ Branch 1 taken 374 times.
3366 for ( int32_t q = 0; q < 8; q++ )
1028 2992 ri->d[q] = combobuf[id].initd[q];
1029 374 data.initialized = true;
1030 374 }
1031
1032 38089 ri->combosref = id; //'this' pointer
1033 38089 ri->comboposref = index; //used for X(), Y(), Layer(), and so forth.
1034 38089 break;
1035 }
1036 }
1037
1038 8923341 return got_initialized;
1039 }
1040
1041 //Sprite script data
1042 refInfo npcScriptData[256];
1043 refInfo lweaponScriptData[256]; //should this be lweapon and eweapon, separate stacks?
1044 refInfo eweaponScriptData[256]; //should this be lweapon and eweapon, separate stacks?
1045 refInfo itemactiveScriptData[256];
1046
1047 int32_t ffmisc[MAXFFCS][16];
1048
1049
3/4
✓ Branch 0 taken 59392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59276 times.
✓ Branch 3 taken 116 times.
59392 user_genscript user_scripts[NUMSCRIPTSGENERIC];
1050 int32_t genscript_timing = SCR_TIMING_START_FRAME;
1051 static word max_valid_genscript;
1052 static dword max_valid_object;
1053
1054 363 void user_genscript::quit()
1055 {
1056 363 doscript = false;
1057
1/2
✓ Branch 0 taken 363 times.
✗ Branch 1 not taken.
363 if(indx > -1)
1058 {
1059 363 FFCore.deallocateAllScriptOwned(ScriptType::Generic, indx);
1060 363 }
1061 363 }
1062
1063 531 void countGenScripts()
1064 {
1065 531 max_valid_genscript = 0;
1066
2/2
✓ Branch 0 taken 271341 times.
✓ Branch 1 taken 531 times.
271872 for(auto q = 1; q < NUMSCRIPTSGENERIC; ++q)
1067 {
1068
4/4
✓ Branch 0 taken 212065 times.
✓ Branch 1 taken 59276 times.
✓ Branch 2 taken 211910 times.
✓ Branch 3 taken 155 times.
271341 if(genericscripts[q] && genericscripts[q]->valid())
1069 155 max_valid_genscript = q;
1070 271341 }
1071 531 }
1072 409 void countObjects()
1073 {
1074 409 max_valid_object = 0;
1075
2/2
✓ Branch 0 taken 87831932 times.
✓ Branch 1 taken 409 times.
87832341 for(auto q = 0; q < MAX_USER_OBJECTS; ++q)
1076 {
1077
1/2
✓ Branch 0 taken 87831932 times.
✗ Branch 1 not taken.
87831932 if(script_objects[q].reserved)
1078 max_valid_object = q+1;
1079 87831932 }
1080 409 }
1081 19594 void timeExitAllGenscript(byte exState)
1082 {
1083
2/2
✓ Branch 0 taken 10032128 times.
✓ Branch 1 taken 19594 times.
10051722 for(user_genscript& g : user_scripts)
1084 10032128 g.timeExit(exState);
1085 19594 }
1086 303804 void throwGenScriptEvent(int32_t event)
1087 {
1088
2/2
✓ Branch 0 taken 38899 times.
✓ Branch 1 taken 303804 times.
342703 for(auto q = 1; q <= max_valid_genscript; ++q)
1089 {
1090 38899 user_genscript& scr = user_scripts[q];
1091
2/2
✓ Branch 0 taken 12956 times.
✓ Branch 1 taken 25943 times.
38899 if(!scr.doscript) continue;
1092
2/2
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 3238 times.
12956 if(!genericscripts[q]->valid()) continue;
1093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9718 times.
9718 if(!scr.waitevent) continue;
1094 if(scr.eventstate & (1<<event))
1095 {
1096 scr.ri.d[rEXP1] = event*10000;
1097 scr.waitevent = false;
1098
1099 //Run the script!
1100 ZScriptVersion::RunScript(ScriptType::Generic, q, q);
1101 }
1102 }
1103 303804 }
1104
1105 74 void load_genscript(const gamedata& gd)
1106 {
1107
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 74 times.
37962 for(size_t q = 0; q < NUMSCRIPTSGENERIC; ++q)
1108 {
1109 37888 user_genscript& gen = user_scripts[q];
1110 37888 gen.clear();
1111 37888 gen.indx = q;
1112 37888 gen.doscript = gd.gen_doscript[q];
1113 37888 gen.exitState = gd.gen_exitState[q];
1114 37888 gen.reloadState = gd.gen_reloadState[q];
1115 37888 gen.eventstate = gd.gen_eventstate[q];
1116 37888 memcpy(gen.initd, gd.gen_initd[q], sizeof(gen.initd));
1117 37888 gen.data = gd.gen_data[q];
1118 37888 gen.dataResize(gd.gen_dataSize[q]);
1119 37888 }
1120 74 }
1121 48 void load_genscript(const zinitdata& zd)
1122 {
1123
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 48 times.
24624 for(size_t q = 0; q < NUMSCRIPTSGENERIC; ++q)
1124 {
1125 24576 user_genscript& gen = user_scripts[q];
1126 24576 gen.clear();
1127 24576 gen.indx = q;
1128 24576 gen.doscript = zd.gen_doscript[q];
1129 24576 gen.exitState = zd.gen_exitState[q];
1130 24576 gen.reloadState = zd.gen_reloadState[q];
1131 24576 gen.eventstate = zd.gen_eventstate[q];
1132 24576 memcpy(gen.initd, zd.gen_initd[q], sizeof(gen.initd));
1133 24576 gen.dataResize(zd.gen_data[q].size());
1134 24576 gen.data = zd.gen_data[q].inner();
1135 24576 gen.dataResize(zd.gen_data[q].size());
1136 24576 }
1137 48 }
1138
1139 void save_genscript(gamedata& gd)
1140 {
1141 for(size_t q = 0; q < NUMSCRIPTSGENERIC; ++q)
1142 {
1143 user_genscript const& gen = user_scripts[q];
1144 gd.gen_doscript[q] = gen.doscript;
1145 gd.gen_exitState[q] = gen.exitState;
1146 gd.gen_reloadState[q] = gen.reloadState;
1147 gd.gen_eventstate[q] = gen.eventstate;
1148 memcpy(gd.gen_initd[q], gen.initd, sizeof(gen.initd));
1149 gd.gen_dataSize[q] = gen.dataSize();
1150 gd.gen_data[q] = gen.data;
1151 }
1152 }
1153
1154 300477265 void FFScript::runGenericPassiveEngine(int32_t scrtm)
1155 {
1156
2/2
✓ Branch 0 taken 3488905 times.
✓ Branch 1 taken 296988360 times.
300477265 if(!max_valid_genscript) return; //No generic scripts in the quest!
1157 //zprint2("Processing timing %d\n", scrtm);
1158 3488905 bool init = (scrtm == SCR_TIMING_INIT);
1159
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3488903 times.
3488905 if(!init)
1160 {
1161
2/2
✓ Branch 0 taken 22439 times.
✓ Branch 1 taken 3466464 times.
3488903 if(genscript_timing != scrtm)
1162 {
1163 //zprint2("Generic script timing jump: expected '%d', found '%d'\n", genscript_timing, scrtm);
1164
2/2
✓ Branch 0 taken 78875 times.
✓ Branch 1 taken 22439 times.
101314 while(genscript_timing != scrtm)
1165 78875 runGenericPassiveEngine(genscript_timing);
1166 22439 }
1167 3488903 }
1168
2/2
✓ Branch 0 taken 41557265 times.
✓ Branch 1 taken 3488905 times.
45046170 for(auto q = 1; q <= max_valid_genscript; ++q)
1169 {
1170 41557265 user_genscript& scr = user_scripts[q];
1171
2/2
✓ Branch 0 taken 13843030 times.
✓ Branch 1 taken 27714235 times.
41557265 if(!scr.doscript) continue;
1172
2/2
✓ Branch 0 taken 10382275 times.
✓ Branch 1 taken 3460755 times.
13843030 if(!genericscripts[q]->valid()) continue;
1173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10382275 times.
10382275 if(scr.waitevent) continue;
1174
8/8
✓ Branch 0 taken 10382273 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 10204736 times.
✓ Branch 3 taken 177537 times.
✓ Branch 4 taken 10204389 times.
✓ Branch 5 taken 347 times.
✓ Branch 6 taken 9760653 times.
✓ Branch 7 taken 443736 times.
10382275 if(!init && (scr.waituntil > scrtm || (!scr.wait_atleast && scr.waituntil != scrtm)))
1175 9938190 continue;
1176
1177 //Run the script!
1178 444085 ZScriptVersion::RunScript(ScriptType::Generic, q, q);
1179 444085 }
1180
4/4
✓ Branch 0 taken 3488903 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3399462 times.
✓ Branch 3 taken 89441 times.
3488905 if(init || genscript_timing >= SCR_TIMING_END_FRAME)
1181 89443 genscript_timing = SCR_TIMING_START_FRAME;
1182 3399462 else ++genscript_timing;
1183 300477265 }
1184
1185 5241 void FFScript::initZScriptDMapScripts()
1186 {
1187 5241 scriptEngineDatas[{ScriptType::DMap, 0}] = ScriptEngineData();
1188 5241 scriptEngineDatas[{ScriptType::ScriptedPassiveSubscreen, 0}] = ScriptEngineData();
1189 5241 }
1190
1191 754 void FFScript::initZScriptSubscreenScript()
1192 {
1193 754 scriptEngineDatas[{ScriptType::EngineSubscreen, 0}] = ScriptEngineData();
1194 754 }
1195 5266 void FFScript::initZScriptScriptedActiveSubscreen()
1196 {
1197 5266 scriptEngineDatas[{ScriptType::ScriptedActiveSubscreen, 0}] = ScriptEngineData();
1198 5266 }
1199
1200 3 void FFScript::initZScriptOnMapScript()
1201 {
1202 3 scriptEngineDatas[{ScriptType::OnMap, 0}] = ScriptEngineData();
1203 3 }
1204
1205 969 void FFScript::initZScriptHeroScripts()
1206 {
1207 969 scriptEngineDatas[{ScriptType::Player, 0}] = ScriptEngineData();
1208 969 }
1209
1210 907 void FFScript::initZScriptItemScripts()
1211 {
1212
2/2
✓ Branch 0 taken 232192 times.
✓ Branch 1 taken 907 times.
233099 for ( int32_t q = 0; q < 256; q++ )
1213 {
1214 232192 auto& data = get_script_engine_data(ScriptType::Item, q);
1215 232192 data.reset();
1216
2/2
✓ Branch 0 taken 232190 times.
✓ Branch 1 taken 2 times.
232192 data.doscript = (itemsbuf[q].flags&ITEM_PASSIVESCRIPT) && game->item[q];
1217 232192 }
1218
1219
2/2
✓ Branch 0 taken 232192 times.
✓ Branch 1 taken 907 times.
233099 for ( int32_t q = -256; q < 0; q++ )
1220 {
1221 232192 auto& data = get_script_engine_data(ScriptType::Item, q);
1222 232192 data.reset();
1223 232192 data.doscript = 0;
1224 232192 }
1225 907 }
1226
1227 2574844 static int get_mouse_state(int index)
1228 {
1229 2574844 int value = 0;
1230
1/2
✓ Branch 0 taken 2574844 times.
✗ Branch 1 not taken.
2574844 if (replay_is_replaying())
1231 {
1232 2574844 value = replay_get_mouse(index);
1233 2574844 }
1234 else if (index == 0)
1235 {
1236 value = script_mouse_x;
1237 }
1238 else if (index == 1)
1239 {
1240 value = script_mouse_y;
1241 }
1242 else if (index == 2)
1243 {
1244 value = script_mouse_z;
1245 }
1246 else if (index == 3)
1247 {
1248 value = script_mouse_b;
1249 }
1250
1251
1/2
✓ Branch 0 taken 2574844 times.
✗ Branch 1 not taken.
2574844 if (replay_is_recording())
1252 {
1253 replay_set_mouse(index, value);
1254 }
1255
1256 2574844 return value;
1257 }
1258
1259 ///----------------------------------------------//
1260 // New Mapscreen Flags Tools //
1261 ///----------------------------------------------//
1262
1263 /*
1264 void FFScript::set_mapscreenflag_state(mapscr *m, int32_t flagid, bool state)
1265 {
1266 switch(flagid)
1267 {
1268 // Room Types
1269 case MSF_INTERIOR:
1270 if ( state )
1271 m->flags6 |= 1;
1272 else m->flags6 &= ~1;
1273 break;
1274 case MSF_DUNGEON:
1275 if ( state )
1276 m->flags6 |= 2;
1277 else m->flags6 &= ~2;
1278 break;
1279 case MSF_SIDEVIEW:
1280 if ( state )
1281 m->flags7 |= 8;
1282 else m->flags7 &= ~8;
1283 break;
1284
1285 // View
1286 case MSF_INVISHERO:
1287 if ( state )
1288 m->flags3 |= 8;
1289 else m->flags3 &= ~8;
1290 break;
1291 case MSF_NOHEROMARKER:
1292 if ( state )
1293 m->flags7 |= 16;
1294 else m->flags7 &= ~16;
1295 break;
1296
1297 case MSF_NOSUBSCREEN:
1298 if ( state )
1299 m->flags3 |= 16;
1300 else m->flags3 &= ~16;
1301 break;
1302 case MSF_NOOFFSET:
1303 if ( state )
1304 m->flags3 |= 64;
1305 else m->flags3 &= ~64;
1306 break;
1307
1308 case MSF_LAYER2BG:
1309 if ( state )
1310 m->flags7 |= 2;
1311 else m->flags7 &= ~2;
1312 break;
1313 case MSF_LAYER3BG:
1314 if ( state )
1315 m->flags7 |= 1;
1316 else m->flags7 &= ~1;
1317 break;
1318 case MSF_DARKROOM:
1319 if ( state )
1320 m->flags |= 4;
1321 else m->flags &= ~4;
1322 break;
1323
1324 // Secrets
1325 case MSF_BLOCKSHUT:
1326 if ( state )
1327 m->flags |= 1;
1328 else m->flags &= ~1;
1329 break;
1330 case MSF_TEMPSECRETS:
1331 if ( state )
1332 m->flags5 |= 16;
1333 else m->flags5 &= ~16;
1334 break;
1335
1336 case MSF_TRIGPERM:
1337 if ( state )
1338 m->flags6 |= 4;
1339 else m->flags6 &= ~4;
1340 break;
1341 case MSF_ALLTRIGFLAGS:
1342 if ( state )
1343 m->flags6 |= 32;
1344 else m->flags6 &= ~32;
1345 break;
1346 // Warp
1347 case MSF_AUTODIRECT:
1348 if ( state )
1349 m->flags5 |= 4;
1350 else m->flags5 &= ~4;
1351 break;
1352 case MSF_SENDSIRECT:
1353 if ( state )
1354 m->flags5 |= 8;
1355 else m->flags5 &= ~8;
1356 break;
1357 case MSF_MAZEPATHS:
1358 if ( state )
1359 m->flags |= 64;
1360 else m->flags &= ~64;
1361 break;
1362
1363 case MSF_MAZEOVERRIDE:
1364 if ( state )
1365 m->flags8 |= 64;
1366 else m->flags8 &= ~64;
1367 break;
1368 case MSF_SPRITECARRY:
1369 if ( state )
1370 m->flags3 |= 32;
1371 else m->flags3 &= ~32;
1372 break;
1373
1374 case MSF_DIRECTTIMEDWARPS:
1375 if ( state )
1376 m->flags4 |= 4;
1377 else m->flags4 &= ~4;
1378 break;
1379
1380 case MSF_SECRETSISABLETIMEWRP:
1381 if ( state )
1382 m->flags4 |= 8;
1383 else m->flags4 &= ~8;
1384 break;
1385 case MSF_RANDOMTIMEDWARP:
1386 if ( state )
1387 m->flags5 |= 1;
1388 else m->flags5 &= ~1;
1389 break;
1390
1391 // Item
1392 case MSF_HOLDUP:
1393 if ( state )
1394 m->flags3 |= 1;
1395 else m->flags3 &= ~1;
1396 break;
1397
1398 case MSF_FALLS:
1399 if ( state )
1400 m->flags7 |= 4;
1401 else m->flags7 &= ~4;
1402 break;
1403
1404
1405 // Combo
1406 case MSF_MIDAIR:
1407 { //FIX ME!
1408 //! What the ever love of fuck mate?!
1409 // byte *f2 = &(m->flags2);
1410 // f2 >>=4;
1411 // int32_t f = 0;
1412 // f<<=1;
1413 // f |= state ? 1:0;
1414 // m->flags2 &= 0x0F;
1415 // m->flags2 |= f<<4;
1416 //if ( state )
1417 // (m->flags2>>4) |= 2;
1418 //else (m->flags2>>4) &= ~2;
1419 break;
1420 }
1421 case MSF_CYCLEINIT:
1422 if ( state )
1423 m->flags3 |= 2;
1424 else m->flags3 &= ~2;
1425 break;
1426 case MSF_IGNOREBOOTS:
1427 if ( state )
1428 m->flags5 |= 2;
1429 else m->flags5 &= ~2;
1430 break;
1431 case MSF_TOGGLERINGS:
1432 if ( state )
1433 m->flags6 |= 64;
1434 else m->flags6 &= ~64;
1435 break;
1436 // Save
1437 case MSF_SAVECONTHERE:
1438 if ( state )
1439 m->flags4 |= 64;
1440 else m->flags4 &= ~64;
1441 break;
1442 case MSF_SAVEONENTRY:
1443 if ( state )
1444 m->flags4 |= 128;
1445 else m->flags4 &= ~128;
1446 break;
1447
1448 case MSF_CONTHERE:
1449 if ( state )
1450 m->flags6 |= 8;
1451 else m->flags6 &= ~8;
1452 break;
1453
1454 case MSF_NOCONTINUEWARP:
1455 if ( state )
1456 m->flags6 |= 16;
1457 else m->flags6 &= ~16;
1458 break;
1459
1460 // FFC
1461 case MSF_WRAPFFC:
1462 if ( state )
1463 m->flags6 |= 128;
1464 else m->flags6 &= ~128;
1465 break;
1466
1467 case MSF_NOCARRYOVERFFC:
1468 if ( state )
1469 m->flags5 |= 128;
1470 else m->flags5 &= ~128;
1471 break;
1472
1473 // Whistle
1474 case MSF_STAIRS:
1475 if ( state )
1476 m->flags |= 16;
1477 else m->flags &= ~16;
1478 break;
1479 case MSF_PALCHANGE:
1480 if ( state )
1481 m->flags7 |= 64;
1482 else m->flags7 &= ~64;
1483 break;
1484 case MSF_DRYLAKE:
1485 if ( state )
1486 m->flags7 |= 128;
1487 else m->flags7 &= ~128;
1488 break;
1489
1490 // Enemies
1491 case MSF_TRAPS_IGNORE_SOLID:
1492 {
1493 //! What the ever love of fuck mate?!
1494 int32_t f = 0;
1495 f<<=2;
1496 f |= state ? 1:0;
1497 m->flags2 &= 0x0F;
1498 m->flags2 |= f<<4;
1499 break;
1500
1501 //! May be wrong : Might be 4>>4 : ~4>>4;?
1502 //if ( state )
1503 // m->(flags2>>4) |= 4;
1504 //else (flags2>>4) &= ~4;
1505 //break;
1506 }
1507 case MSF_ENEMEIS_SECRET:
1508 {
1509 //! What the ever love of fuck mate?!
1510 int32_t f = 0;
1511 f<<=3;
1512 f |= state ? 1:0;
1513 m->flags2 &= 0x0F;
1514 m->flags2 |= f<<4;
1515 break;
1516
1517 //! May be wrong : Might be 8>>4 : ~8>>4;?
1518 //if ( state )
1519 // m->(flags2>>4) |= 8;
1520 //else (flags2>>4) &= ~8;
1521 //break;
1522 }
1523 case MSF_INVISIBLEENEMIES:
1524 if ( state )
1525 m->flags3 |= 4;
1526 else m->flags3 &= ~4;
1527 case MSF_EMELIESALWAYSRETURN:
1528 if ( state )
1529 m->flags3 |= 128;
1530 else m->flags3 &= ~128;
1531 break;
1532 case MSF_ENEMIES_ITEM:
1533 if ( state )
1534 m->flags |= 2;
1535 else m->flags &= ~2;
1536 break;
1537
1538 case MSF_ENEMIES_SECRET_PERM:
1539 if ( state )
1540 m->flags4 |= 16;
1541 else m->flags4 &= ~16;
1542 break;
1543
1544 case MSF_SPAWN_ZORA:
1545 if ( state )
1546 m->enemyflags |= 1;
1547 else m->enemyflags &= ~1;
1548 break;
1549 case MSF_SPAWN_CORNERTRAP:
1550 if ( state )
1551 m->enemyflags |= 2;
1552 else m->enemyflags &= ~2;
1553 break;
1554 case MSF_SPAWN_MIDDLETRAP:
1555 if ( state )
1556 m->enemyflags |= 4;
1557 else m->enemyflags &= ~4;
1558 break;
1559 case MSF_SPAWN_ROCK:
1560 if ( state )
1561 m->enemyflags |= 8;
1562 else m->enemyflags &= ~8;
1563 break;
1564 case MSF_SPAWN_SHOOTER:
1565 if ( state )
1566 m->enemyflags |= 16;
1567 else m->enemyflags &= ~16;
1568 break;
1569
1570 case MSF_RINGLEADER:
1571 if ( state )
1572 m->enemyflags |= 32;
1573 else m->enemyflags &= ~32;
1574 break;
1575 case MSF_ENEMYHASITEM:
1576 if ( state )
1577 m->enemyflags |= 64;
1578 else m->enemyflags &= ~64;
1579 break;
1580 case MSF_ENEMYISBOSS:
1581 if ( state )
1582 m->enemyflags |= 128;
1583 else m->enemyflags &= ~128;
1584 break;
1585
1586 // Misc
1587 case MSF_ALLOW_LADDER:
1588 if ( state )
1589 m->flags |= 32;
1590 else m->flags &= ~32;
1591 break;
1592 case MSF_NO_DIVING:
1593 if ( state )
1594 m->flags5 |= 64;
1595 else m->flags5 &= ~64;
1596 break;
1597
1598 case MSF_LENSEFFECT:
1599 if ( state )
1600 m->flags8 |= 32;
1601 else m->flags8 &= ~32;
1602 break;
1603
1604 case MSF_SFXONENTRY:
1605 if ( state )
1606 m->flags |= 128;
1607 else m->flags &= ~128;
1608 break;
1609
1610
1611 // Custom / Script
1612 case MSF_SCRIPT1:
1613 if ( state )
1614 m->flags8 |= 1;
1615 else m->flags8 &= ~1;
1616 break;
1617 case MSF_SCRIPT2:
1618 if ( state )
1619 m->flags8 |= 2;
1620 else m->flags8 &= ~2;
1621 break;
1622 case MSF_SCRIPT3:
1623 if ( state )
1624 m->flags8 |= 4;
1625 else m->flags8 &= ~4;
1626 break;
1627 case MSF_SCRIPT4:
1628 if ( state )
1629 m->flags8 |= 8;
1630 else m->flags8 &= ~8;
1631 break;
1632 case MSF_SCRIPT5:
1633 if ( state )
1634 m->flags8 |= 16;
1635 else m->flags8 &= ~16;
1636 break;
1637
1638 //This is a dummy proc, but may have been used at one point in older versions.
1639 case MSF_DUMMY_8:
1640 if ( state )
1641 m->flags |= 8;
1642 else m->flags &= ~8;
1643 break;
1644
1645 default: Z_scripterrlog("Illegal flag value (%d) passed to SetMapscreenFlag", flagid);
1646 }
1647 }
1648
1649 int32_t FFScript::get_mapscreenflag_state(mapscr *m, int32_t flagid)
1650 {
1651 switch(flagid)
1652 {
1653 // Room Types
1654 case MSF_INTERIOR:
1655 return (m->flags6&1) ? 1 : 0;
1656 case MSF_DUNGEON:
1657 return (m->flags6&2) ? 1 : 0;
1658 case MSF_SIDEVIEW:
1659 return (m->flags7&8) ? 1 : 0;
1660
1661 // View
1662 case MSF_INVISHERO:
1663 return (m->flags3&8) ? 1 : 0;
1664 case MSF_NOHEROMARKER:
1665 return (m->flags7&16) ? 1 : 0;
1666
1667 case MSF_NOSUBSCREEN:
1668 return (m->flags3&16) ? 1 : 0;
1669 case MSF_NOOFFSET:
1670 return (m->flags3&64) ? 1 : 0;
1671
1672 case MSF_LAYER2BG:
1673 return (m->flags7&2) ? 1 : 0;
1674 case MSF_LAYER3BG:
1675 return (m->flags7&1) ? 1 : 0;
1676 case MSF_DARKROOM:
1677 return (m->flags&4) ? 1 : 0;
1678
1679 // Secrets
1680 case MSF_BLOCKSHUT:
1681 return (m->flags&1) ? 1 : 0;
1682 case MSF_TEMPSECRETS:
1683 return (m->flags5&16) ? 1 : 0;
1684 case MSF_TRIGPERM:
1685 return (m->flags6&4) ? 1 : 0;
1686 case MSF_ALLTRIGFLAGS:
1687 return (m->flags6&32) ? 1 : 0;
1688
1689 // Warp
1690 case MSF_AUTODIRECT:
1691 return (m->flags5&4) ? 1 : 0;
1692 case MSF_SENDSIRECT:
1693 return (m->flags5&8) ? 1 : 0;
1694 case MSF_MAZEPATHS:
1695 return (m->flags&64) ? 1 : 0;
1696
1697 case MSF_MAZEOVERRIDE:
1698 return (m->flags8&64) ? 1 : 0;
1699 case MSF_SPRITECARRY:
1700 return (m->flags3&32) ? 1 : 0;
1701 case MSF_DIRECTTIMEDWARPS:
1702 return (m->flags4&4) ? 1 : 0;
1703 case MSF_SECRETSISABLETIMEWRP:
1704 return (m->flags4&8) ? 1 : 0;
1705
1706 case MSF_RANDOMTIMEDWARP:
1707 return (m->flags5&1) ? 1 : 0;
1708
1709 // Item
1710 case MSF_HOLDUP:
1711 return (m->flags3&1) ? 1 : 0;
1712 case MSF_FALLS:
1713 return (m->flags7&4) ? 1 : 0;
1714
1715 // Combo
1716 case MSF_MIDAIR:
1717 return ((m->flags2>>4)&2) ? 1 : 0;
1718 case MSF_CYCLEINIT:
1719 return (m->flags3&2) ? 1 : 0;
1720 case MSF_IGNOREBOOTS:
1721 return (m->flags5&2) ? 1 : 0;
1722 case MSF_TOGGLERINGS:
1723 return (m->flags6&64) ? 1 : 0;
1724 // Save
1725 case MSF_SAVECONTHERE:
1726 return (m->flags4&64) ? 1 : 0;
1727 case MSF_SAVEONENTRY:
1728 return (m->flags4&128) ? 1 : 0;
1729
1730 case MSF_CONTHERE:
1731 return (m->flags6&8) ? 1 : 0;
1732
1733 case MSF_NOCONTINUEWARP:
1734 return (m->flags6&16) ? 1 : 0;
1735
1736 // FFC
1737 case MSF_WRAPFFC:
1738 return (m->flags6&128) ? 1 : 0;
1739
1740 case MSF_NOCARRYOVERFFC:
1741 return (m->flags5&128) ? 1 : 0;
1742
1743 // Whistle
1744 case MSF_STAIRS:
1745 return (m->flags&16) ? 1 : 0;
1746 case MSF_PALCHANGE:
1747 return (m->flags7&64) ? 1 : 0;
1748 case MSF_DRYLAKE:
1749 return (m->flags7&128) ? 1 : 0;
1750
1751 // Enemies
1752 case MSF_TRAPS_IGNORE_SOLID:
1753 //! May be wrong : Might be 4>>4 : ~4>>4;?
1754 return ((m->flags2>>4)&4) ? 1 : 0;
1755
1756 case MSF_ENEMEIS_SECRET:
1757 //! May be wrong : Might be 8>>4 : ~8>>4;?
1758 return ((m->flags2>>4)&8) ? 1 : 0;
1759
1760 case MSF_ENEMIES_SECRET_PERM:
1761 return (m->flags4&16) ? 1 : 0;
1762
1763 case MSF_SPAWN_ZORA:
1764 return (m->enemyflags&1) ? 1 : 0;
1765
1766 case MSF_SPAWN_CORNERTRAP:
1767 return (m->enemyflags&2) ? 1 : 0;
1768
1769 case MSF_SPAWN_MIDDLETRAP:
1770 return (m->enemyflags&3) ? 1 : 0;
1771
1772 case MSF_SPAWN_ROCK:
1773 return (m->enemyflags&4) ? 1 : 0;
1774
1775 case MSF_SPAWN_SHOOTER:
1776 return (m->enemyflags&16) ? 1 : 0;
1777
1778 case MSF_RINGLEADER:
1779 return (m->enemyflags&32) ? 1 : 0;
1780
1781 case MSF_ENEMYHASITEM:
1782 return (m->enemyflags&64) ? 1 : 0;
1783 case MSF_ENEMYISBOSS:
1784 return (m->enemyflags&128) ? 1 : 0;
1785
1786 case MSF_INVISIBLEENEMIES:
1787 return (m->flags3&4) ? 1 : 0;
1788 case MSF_EMELIESALWAYSRETURN:
1789 return (m->flags3&128) ? 1 : 0;
1790
1791 case MSF_ENEMIES_ITEM:
1792 return (m->flags&2) ? 1 : 0;
1793
1794 // Misc
1795 case MSF_ALLOW_LADDER:
1796 return (m->flags&32) ? 1 : 0;
1797 case MSF_NO_DIVING:
1798 return (m->flags5&64) ? 1 : 0;
1799
1800 case MSF_LENSEFFECT:
1801 return (m->flags8&32) ? 1 : 0;
1802
1803 case MSF_SFXONENTRY:
1804 return (m->flags&128) ? 1 : 0;
1805
1806 //Custom / Script
1807 case MSF_SCRIPT1:
1808 return (m->flags8&1) ? 1 : 0;
1809 case MSF_SCRIPT2:
1810 return (m->flags8&2) ? 1 : 0;
1811 case MSF_SCRIPT3:
1812 return (m->flags8&4) ? 1 : 0;
1813 case MSF_SCRIPT4:
1814 return (m->flags8&8) ? 1 : 0;
1815 case MSF_SCRIPT5:
1816 return (m->flags8&16) ? 1 : 0;
1817
1818 //This is a dummy proc, but may have been used at one point in older versions.
1819 case MSF_DUMMY_8:
1820 return (m->flags&8) ? 1 : 0;
1821
1822
1823 default:
1824 {
1825 Z_scripterrlog("Illegal flag value (%d) passed to GetMapscreenFlag", flagid);
1826 return -1;
1827 }
1828 }
1829 }
1830 */
1831 //ScriptHelper
1832 class SH
1833 {
1834
1835 ///-----------------------------//
1836 // Errors //
1837 ///-----------------------------//
1838
1839 public:
1840
1841 enum __Error
1842 {
1843 _NoError, //OK!
1844 _Overflow, //script array too small
1845 _InvalidPointer, //passed NULL pointer or similar
1846 _OutOfBounds, //library array out of bounds
1847 _InvalidSpriteUID //bad npc, ffc, etc.
1848 };
1849
1850 #define INVALIDARRAY localRAM[0] //localRAM[0] is never used
1851
1852 //only if the player is messing with their pointers...
1853 static ZScriptArray& InvalidError(const int32_t ptr)
1854 {
1855 Z_scripterrlog("Invalid pointer (%i) passed to array (don't change the values of your array pointers)\n", ptr);
1856 return INVALIDARRAY;
1857 }
1858
1859 static void write_stack(const uint32_t stackoffset, const int32_t value)
1860 {
1861 if(stackoffset >= MAX_SCRIPT_REGISTERS)
1862 {
1863 Z_scripterrlog("Stack over or underflow, stack pointer = %ld\n", stackoffset);
1864 return;
1865 }
1866
1867 (*stack)[stackoffset] = value;
1868 }
1869
1870 305947266 static int32_t read_stack(const uint32_t stackoffset)
1871 {
1872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 305947266 times.
305947266 if(stackoffset >= MAX_SCRIPT_REGISTERS)
1873 {
1874 Z_scripterrlog("Stack over or underflow, stack pointer = %ld\n", stackoffset);
1875 return -10000;
1876 }
1877
1878 305947266 return (*stack)[stackoffset];
1879 305947266 }
1880
1881 391981453 static INLINE int32_t get_arg(int32_t arg, bool v)
1882 {
1883
2/2
✓ Branch 0 taken 67951142 times.
✓ Branch 1 taken 324030311 times.
391981453 return v ? arg : get_register(arg);
1884 }
1885 };
1886
1887 ///----------------------------//
1888 // Misc. //
1889 ///----------------------------//
1890
1891 //Miscellaneous Helper
1892 class MiscH : public SH
1893 {
1894 public:
1895
1896 };
1897
1898 byte flagpos;
1899 int32_t flagval;
1900 11837886 void clear_ornextflag()
1901 {
1902 11837886 flagpos = 0;
1903 11837886 flagval = 0;
1904 11837886 }
1905 77407187 void ornextflag(bool flag)
1906 {
1907
2/2
✓ Branch 0 taken 75940095 times.
✓ Branch 1 taken 1467092 times.
77407187 if(flag) flagval |= 1<<flagpos;
1908 77407187 ++flagpos;
1909 77407187 }
1910
1911 6641186 int32_t get_screenflags(mapscr *m, int32_t flagset)
1912 {
1913 6641186 clear_ornextflag();
1914
1915
3/11
✓ Branch 0 taken 3734958 times.
✓ Branch 1 taken 2816619 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 89609 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
6641186 switch(flagset)
1916 {
1917 case 0: // Room Type
1918 3734958 ornextflag(m->flags6&1);
1919 3734958 ornextflag(m->flags6&2);
1920 3734958 ornextflag(m->flags7&8);
1921 3734958 break;
1922
1923 case 1: // View
1924 2816619 ornextflag(m->flags3&8);
1925 2816619 ornextflag(m->flags7&16);
1926 2816619 ornextflag(m->flags3&16);
1927 2816619 ornextflag(m->flags3&64);
1928 2816619 ornextflag(m->flags7&2);
1929 2816619 ornextflag(m->flags7&1);
1930 2816619 ornextflag(m->flags&fDARK);
1931 2816619 ornextflag(m->flags9&fDARK_DITHER);
1932 2816619 ornextflag(m->flags9&fDARK_TRANS);
1933 2816619 break;
1934
1935 case 2: // Secrets
1936 ornextflag(m->flags&1);
1937 ornextflag(m->flags5&16);
1938 ornextflag(m->flags6&4);
1939 ornextflag(m->flags6&32);
1940 break;
1941
1942 case 3: // Warp
1943 ornextflag(m->flags5&4);
1944 ornextflag(m->flags5&8);
1945 ornextflag(m->flags&64);
1946 ornextflag(m->flags8&64);
1947 ornextflag(m->flags3&32);
1948 ornextflag(m->flags9&fDISABLE_MIRROR);
1949 break;
1950
1951 case 4: // Item
1952 ornextflag(m->flags3&1);
1953 ornextflag(m->flags7&4);
1954 ornextflag(m->flags8&0x40);
1955 ornextflag(m->flags8&0x80);
1956 ornextflag(m->flags9&0x01);
1957 ornextflag(m->flags9&0x02);
1958 ornextflag(m->flags9&0x04);
1959 break;
1960
1961 case 5: // Combo
1962 ornextflag((m->flags2>>4)&2);
1963 ornextflag(m->flags3&2);
1964 ornextflag(m->flags5&2);
1965 ornextflag(m->flags6&64);
1966 break;
1967
1968 case 6: // Save
1969 ornextflag(m->flags4&64);
1970 ornextflag(m->flags4&128);
1971 ornextflag(m->flags6&8);
1972 ornextflag(m->flags6&16);
1973 break;
1974
1975 case 7: // FFC
1976 ornextflag(m->flags6&128);
1977 ornextflag(m->flags5&128);
1978 break;
1979
1980 case 8: // Whistle
1981 ornextflag(m->flags&16);
1982 ornextflag(m->flags7&64);
1983 ornextflag(m->flags7&128);
1984 break;
1985
1986 case 9: // Misc
1987 89609 ornextflag(m->flags&32);
1988 89609 ornextflag(m->flags5&64);
1989 89609 flagval |= m->flags8<<2;
1990 89609 break;
1991 }
1992
1993 6641186 return flagval*10000;
1994 }
1995
1996 1524194 int32_t get_screeneflags(mapscr *m, int32_t flagset)
1997 {
1998 1524194 clear_ornextflag();
1999
2000
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1524194 times.
✗ Branch 3 not taken.
1524194 switch(flagset)
2001 {
2002 case 0:
2003 flagval |= m->enemyflags&0x1F;
2004 break;
2005
2006 case 1:
2007 1524194 ornextflag(m->enemyflags&32);
2008 1524194 ornextflag(m->enemyflags&64);
2009 1524194 ornextflag(m->flags3&4);
2010 1524194 ornextflag(m->enemyflags&128);
2011 1524194 ornextflag((m->flags2>>4)&4);
2012 1524194 break;
2013
2014 case 2:
2015 ornextflag(m->flags3&128);
2016 ornextflag(m->flags&2);
2017 ornextflag((m->flags2>>4)&8);
2018 ornextflag(m->flags4&16);
2019 ornextflag(m->flags9&fENEMY_WAVES);
2020 break;
2021 }
2022
2023 1524194 return flagval*10000;
2024 }
2025
2026 1263407 int32_t get_mi(int32_t ref = MAPSCR_TEMP0)
2027 {
2028
2/2
✓ Branch 0 taken 45056 times.
✓ Branch 1 taken 1218351 times.
1263407 if(ref >= 0)
2029 45056 return ref - (8*(ref / MAPSCRS));
2030
1/3
✓ Branch 0 taken 1218351 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
1218351 switch(ref)
2031 {
2032 case MAPSCR_TEMP0: case MAPSCR_TEMP1: case MAPSCR_TEMP2: case MAPSCR_TEMP3:
2033 case MAPSCR_TEMP4: case MAPSCR_TEMP5: case MAPSCR_TEMP6:
2034 1218351 return (currmap*MAPSCRSNORMAL)+homescr;
2035 case MAPSCR_SCROLL0: case MAPSCR_SCROLL1: case MAPSCR_SCROLL2: case MAPSCR_SCROLL3:
2036 case MAPSCR_SCROLL4: case MAPSCR_SCROLL5: case MAPSCR_SCROLL6:
2037 return (scrolling_map*MAPSCRSNORMAL)+scrolling_scr;
2038 }
2039 return -1;
2040 1263407 }
2041
2042 int32_t get_total_mi(int32_t ref = MAPSCR_TEMP0)
2043 {
2044 if(ref >= 0)
2045 return ref;
2046 switch(ref)
2047 {
2048 case MAPSCR_TEMP0: case MAPSCR_TEMP1: case MAPSCR_TEMP2: case MAPSCR_TEMP3:
2049 case MAPSCR_TEMP4: case MAPSCR_TEMP5: case MAPSCR_TEMP6:
2050 return (currmap*MAPSCRS)+currscr;
2051 case MAPSCR_SCROLL0: case MAPSCR_SCROLL1: case MAPSCR_SCROLL2: case MAPSCR_SCROLL3:
2052 case MAPSCR_SCROLL4: case MAPSCR_SCROLL5: case MAPSCR_SCROLL6:
2053 return (scrolling_map*MAPSCRS)+scrolling_scr;
2054 }
2055 return -1;
2056 }
2057
2058 ///------------------------------------------------//
2059 // Bounds Checking Functions //
2060 ///------------------------------------------------//
2061
2062 //Bounds Checker
2063 class BC : public SH
2064 {
2065 public:
2066
2067 18740053 static INLINE int32_t checkMapID(const int32_t ID, const char * const str)
2068 {
2069 //return checkBounds(ID, 0, map_count-1, str);
2070
2/4
✓ Branch 0 taken 18740053 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18740053 times.
18740053 if(ID < 0 || ID > map_count-1)
2071 {
2072 Z_scripterrlog("Invalid value (%i) passed to '%s'\n", ID+1, str);
2073 return _OutOfBounds;
2074 }
2075
2076 18740053 return _NoError;
2077 18740053 }
2078
2079 2873569 static INLINE int32_t checkDMapID(const int32_t ID, const char * const str)
2080 {
2081 2873569 return checkBounds(ID, 0, MAXDMAPS-1, str);
2082 }
2083
2084 81864157 static INLINE int32_t checkComboPos(const int32_t pos, const char * const str)
2085 {
2086 81864157 return checkBoundsPos(pos, 0, 175, str);
2087 }
2088
2089 127665 static INLINE int32_t checkTile(const int32_t pos, const char * const str)
2090 {
2091 127665 return checkBounds(pos, 0, NEWMAXTILES-1, str);
2092 }
2093
2094 2564 static INLINE int32_t checkCombo(const int32_t pos, const char * const str)
2095 {
2096 2564 return checkBounds(pos, 0, MAXCOMBOS-1, str);
2097 }
2098
2099 6076 static INLINE int32_t checkMisc(const int32_t a, const char * const str)
2100 {
2101 6076 return checkBounds(a, 0, 15, str);
2102 }
2103
2104 13999164 static INLINE int32_t checkMisc32(const int32_t a, const char * const str)
2105 {
2106 13999164 return checkBounds(a, 0, 31, str);
2107 }
2108
2109 3839 static INLINE int32_t checkMessage(const int32_t ID, const char * const str)
2110 {
2111 3839 return checkBounds(ID, 0, msg_strings_size-1, str);
2112 }
2113
2114 static INLINE int32_t checkLayer(const int32_t layer, const char * const str)
2115 {
2116 return checkBounds(layer, 0, 6, str);
2117 }
2118
2119 503812264 static INLINE int32_t checkFFC(const int32_t ffc, const char * const str)
2120 {
2121 503812264 return checkBounds(ffc, 0, MAXFFCS-1, str);
2122 }
2123
2124 15644354 static INLINE int32_t checkGuyIndex(const int32_t index, const char * const str)
2125 {
2126 15644354 return checkBoundsOneIndexed(index, 0, guys.Count()-1, str);
2127 }
2128
2129 136832 static INLINE int32_t checkItemIndex(const int32_t index, const char * const str)
2130 {
2131 136832 return checkBoundsOneIndexed(index, 0, items.Count()-1, str);
2132 }
2133
2134 2753647 static INLINE int32_t checkEWeaponIndex(const int32_t index, const char * const str)
2135 {
2136 2753647 return checkBoundsOneIndexed(index, 0, Ewpns.Count()-1, str);
2137 }
2138
2139 1201098 static INLINE int32_t checkLWeaponIndex(const int32_t index, const char * const str)
2140 {
2141 1201098 return checkBoundsOneIndexed(index, 0, Lwpns.Count()-1, str);
2142 }
2143
2144 2363 static INLINE int32_t checkGuyID(const int32_t ID, const char * const str)
2145 {
2146 //return checkBounds(ID, 0, MAXGUYS-1, str); //Can't create NPC ID 0
2147 2363 return checkBounds(ID, 1, MAXGUYS-1, str);
2148 }
2149
2150 1838278 static INLINE int32_t checkItemID(const int32_t ID, const char * const str)
2151 {
2152 1838278 return checkBounds(ID, 0, MAXITEMS-1, str);
2153 }
2154
2155 209195 static INLINE int32_t checkWeaponID(const int32_t ID, const char * const str)
2156 {
2157 209195 return checkBounds(ID, 0, MAXWPNS-1, str);
2158 }
2159
2160 147223 static INLINE int32_t checkWeaponMiscSprite(const int32_t ID, const char * const str)
2161 {
2162 147223 return checkBounds(ID, 0, MAXWPNS-1, str);
2163 }
2164
2165 170878 static INLINE int32_t checkSFXID(const int32_t ID, const char * const str)
2166 {
2167 170878 return checkBounds(ID, 0, WAV_COUNT-1, str);
2168 }
2169
2170 560413900 static INLINE int32_t checkBounds(const int32_t n, const int32_t boundlow, const int32_t boundup, const char * const funcvar)
2171 {
2172
4/4
✓ Branch 0 taken 560413896 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 229 times.
✓ Branch 3 taken 560413667 times.
560413900 if(n < boundlow || n > boundup)
2173 {
2174 233 Z_scripterrlog("Invalid value (%i) passed to '%s'\n", n, funcvar);
2175 233 return _OutOfBounds;
2176 }
2177
2178 560413667 return _NoError;
2179 560413900 }
2180
2181 81864157 static INLINE int32_t checkBoundsPos(const int32_t n, const int32_t boundlow, const int32_t boundup, const char * const funcvar)
2182 {
2183
3/4
✓ Branch 0 taken 81864157 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1584 times.
✓ Branch 3 taken 81862573 times.
81864157 if(n < boundlow || n > boundup)
2184 {
2185 1584 Z_scripterrlog("Invalid position [%i] used to read to '%s'\n", n, funcvar);
2186 1584 return _OutOfBounds;
2187 }
2188
2189 81862573 return _NoError;
2190 81864157 }
2191
2192 19735931 static INLINE int32_t checkBoundsOneIndexed(const int32_t n, const int32_t boundlow, const int32_t boundup, const char * const funcvar)
2193 {
2194
4/4
✓ Branch 0 taken 19722168 times.
✓ Branch 1 taken 13763 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 19722094 times.
19735931 if(n < boundlow || n > boundup)
2195 {
2196 13837 Z_scripterrlog("Invalid value (%i) passed to '%s'\n", n+1, funcvar);
2197 13837 return _OutOfBounds;
2198 }
2199
2200 19722094 return _NoError;
2201 19735931 }
2202
2203 1635286268 static INLINE int32_t checkUserArrayIndex(const int32_t index, const dword size, const bool neg = false)
2204 {
2205
2206
6/6
✓ Branch 0 taken 40576519 times.
✓ Branch 1 taken 1594709749 times.
✓ Branch 2 taken 1634653187 times.
✓ Branch 3 taken 633081 times.
✓ Branch 4 taken 7038 times.
✓ Branch 5 taken 1634646149 times.
1635286268 if(index < (neg ? -int32_t(size) : 0) || index >= int32_t(size))
2207 {
2208 640119 Z_scripterrlog("Invalid index (%ld) to local array of size %ld\n", index, size);
2209 640119 return _OutOfBounds;
2210 }
2211
2212 1634646149 return _NoError;
2213 1635286268 }
2214 };
2215
2216 ///------------------------------------------------//
2217 // Pointer Handling Functions //
2218 ///------------------------------------------------//
2219 //MUST call AND check load functions before trying to use other functions
2220
2221
2222
2223
2224 //Guy Helper
2225 class GuyH : public SH
2226 {
2227
2228 public:
2229 78146347 static int32_t loadNPC(const int32_t eid, const char * const funcvar)
2230 {
2231
2/2
✓ Branch 0 taken 78146200 times.
✓ Branch 1 taken 147 times.
78146347 if ( !eid )
2232 {
2233 //can never be zero?
2234 147 Z_scripterrlog("The npc pointer used for %s is NULL or uninitialised.", funcvar);
2235 147 return _InvalidSpriteUID;
2236 }
2237 78146200 tempenemy = (enemy *) guys.getByUID(eid);
2238
2239
2/2
✓ Branch 0 taken 5901 times.
✓ Branch 1 taken 78140299 times.
78146200 if(tempenemy == NULL)
2240 {
2241 5901 Z_scripterrlog("Invalid NPC with UID %ld passed to %s\nNPCs on screen have UIDs ", eid, funcvar);
2242
2243
2/2
✓ Branch 0 taken 13743 times.
✓ Branch 1 taken 5901 times.
19644 for(word i = 0; i < guys.Count(); i++)
2244 13743 Z_scripterrlog("%ld ", guys.spr(i)->getUID());
2245
2246 5901 Z_scripterrlog("\n");
2247 5901 return _InvalidSpriteUID;
2248 }
2249
2250 78140299 return _NoError;
2251 78146347 }
2252
2253 73341958 static INLINE enemy *getNPC()
2254 {
2255 73341958 return tempenemy;
2256 }
2257
2258 // Currently only used in a context where the enemy is known to be valid,
2259 // so there's no need to print an error
2260 2 static int32_t getNPCIndex(const int32_t eid)
2261 {
2262
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 for(word i = 0; i < guys.Count(); i++)
2263 {
2264
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(guys.spr(i)->getUID() == eid)
2265 2 return i;
2266 }
2267
2268 return -1;
2269 2 }
2270
2271 6431345 static int32_t getNPCDMisc(const byte a)
2272 {
2273
12/33
✓ Branch 0 taken 2129 times.
✓ Branch 1 taken 9365 times.
✓ Branch 2 taken 1308 times.
✓ Branch 3 taken 5650 times.
✓ Branch 4 taken 874 times.
✓ Branch 5 taken 742 times.
✓ Branch 6 taken 107 times.
✓ Branch 7 taken 64 times.
✓ Branch 8 taken 391 times.
✓ Branch 9 taken 383 times.
✓ Branch 10 taken 3262601 times.
✓ Branch 11 taken 3147731 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
6431345 switch(a)
2274 {
2275 2129 case 0: return tempenemy->dmisc1;
2276 9365 case 1: return tempenemy->dmisc2;
2277 1308 case 2: return tempenemy->dmisc3;
2278 5650 case 3: return tempenemy->dmisc4;
2279 874 case 4: return tempenemy->dmisc5;
2280 742 case 5: return tempenemy->dmisc6;
2281 107 case 6: return tempenemy->dmisc7;
2282 64 case 7: return tempenemy->dmisc8;
2283 391 case 8: return tempenemy->dmisc9;
2284 383 case 9: return tempenemy->dmisc10;
2285 3262601 case 10: return tempenemy->dmisc11;
2286 3147731 case 11: return tempenemy->dmisc12;
2287 case 12: return tempenemy->dmisc13;
2288 case 13: return tempenemy->dmisc14;
2289 case 14: return tempenemy->dmisc15;
2290 case 15: return tempenemy->dmisc16;
2291 case 16: return tempenemy->dmisc17;
2292 case 17: return tempenemy->dmisc18;
2293 case 18: return tempenemy->dmisc19;
2294 case 19: return tempenemy->dmisc20;
2295 case 20: return tempenemy->dmisc21;
2296 case 21: return tempenemy->dmisc22;
2297 case 22: return tempenemy->dmisc23;
2298 case 23: return tempenemy->dmisc24;
2299 case 24: return tempenemy->dmisc25;
2300 case 25: return tempenemy->dmisc26;
2301 case 26: return tempenemy->dmisc27;
2302 case 27: return tempenemy->dmisc28;
2303 case 28: return tempenemy->dmisc29;
2304 case 29: return tempenemy->dmisc30;
2305 case 30: return tempenemy->dmisc31;
2306 case 31: return tempenemy->dmisc32;
2307 }
2308
2309 return 0;
2310 6431345 }
2311
2312 4023636 static bool hasHero()
2313 {
2314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4023636 times.
4023636 if(tempenemy->family == eeWALLM)
2315 return ((eWallM *) tempenemy)->hashero;
2316
2317
2/2
✓ Branch 0 taken 221194 times.
✓ Branch 1 taken 3802442 times.
4023636 if(tempenemy->family == eeWALK)
2318 221194 return ((eStalfos *) tempenemy)->hashero;
2319
2320 3802442 return false;
2321 4023636 }
2322
2323 3672506 static int32_t getMFlags()
2324 {
2325 3672506 clear_ornextflag();
2326 3672506 flagpos = 5;
2327 // Must be in the same order as in the Enemy Editor pane
2328 3672506 ornextflag(tempenemy->flags&(lens_only));
2329 3672506 ornextflag(tempenemy->flags2&(guy_flashing));
2330 3672506 ornextflag(tempenemy->flags2&(guy_blinking));
2331 3672506 ornextflag(tempenemy->flags2&(guy_transparent));
2332 3672506 ornextflag(tempenemy->flags&(inv_front));
2333 3672506 ornextflag(tempenemy->flags&(inv_left));
2334 3672506 ornextflag(tempenemy->flags&(inv_right));
2335 3672506 ornextflag(tempenemy->flags&(inv_back));
2336 3672506 ornextflag(tempenemy->flags&(guy_bkshield));
2337 3672506 return (tempenemy->flags&0x1F) | flagval;
2338 }
2339
2340 16355 static INLINE void clearTemp()
2341 {
2342 16355 tempenemy = NULL;
2343 16355 }
2344
2345 private:
2346
2347 static enemy *tempenemy;
2348 };
2349
2350 enemy *GuyH::tempenemy = NULL;
2351
2352 //Item Helper
2353 class ItemH : public SH
2354 {
2355
2356 public:
2357 static int32_t loadItem(const int32_t iid, const char * const funcvar)
2358 {
2359 if ( !iid )
2360 {
2361 //can never be zero?
2362 Z_scripterrlog("The item pointer used for %s is NULL or uninitialised.", funcvar);
2363 return _InvalidSpriteUID;
2364 }
2365
2366 tempitem = (item *) items.getByUID(iid);
2367
2368 if(tempitem == NULL)
2369 {
2370 Z_scripterrlog("Invalid item with UID %ld passed to %s\nItems on screen have UIDs ", iid, funcvar);
2371
2372 for(word i = 0; i < items.Count(); i++)
2373 Z_scripterrlog("%ld ", items.spr(i)->getUID());
2374
2375 Z_scripterrlog("\n");
2376 return _InvalidSpriteUID;
2377 }
2378
2379 return _NoError;
2380 }
2381
2382 2645 static int32_t getItemIndex(const int32_t iid)
2383 {
2384
1/2
✓ Branch 0 taken 3957 times.
✗ Branch 1 not taken.
3957 for(word i = 0; i < items.Count(); i++)
2385 {
2386
2/2
✓ Branch 0 taken 2645 times.
✓ Branch 1 taken 1312 times.
3957 if(items.spr(i)->getUID() == iid)
2387 2645 return i;
2388 1312 }
2389
2390 return -1;
2391 2645 }
2392
2393 static INLINE item* getItem()
2394 {
2395 return tempitem;
2396 }
2397
2398 16355 static INLINE void clearTemp()
2399 {
2400 16355 tempitem = NULL;
2401 16355 }
2402
2403 private:
2404
2405 static item *tempitem;
2406 };
2407
2408 item *ItemH::tempitem = NULL;
2409
2410 //LWeapon Helper
2411 class LwpnH : public SH
2412 {
2413
2414 public:
2415
2416
2417 static defWpnSprite getDefWeaponSprite(weapon *wp)
2418 {
2419 switch(wp->id)
2420 {
2421 case wNone: return ws_0;
2422 case wSword: return ws_0;
2423 case wBeam: return wsBeam;
2424 case wBrang : return wsBrang;
2425 case wBomb: return wsBomb;
2426 case wSBomb: return wsSBomb;
2427 case wLitBomb: return wsBombblast;
2428 case wLitSBomb: return wsBombblast;
2429 case wArrow: return wsArrow;
2430 case wFire: return wsFire;
2431 case wWhistle: return wsUnused45;
2432 case wBait: return wsBait;
2433 case wWand: return wsWandHandle;
2434 case wMagic: return wsMagic;
2435 case wCatching: return wsUnused45;
2436 case wWind: return wsWind;
2437 case wRefMagic: return wsRefMagic;
2438 case wRefFireball: return wsRefFireball;
2439 case wRefRock: return wsRock;
2440 case wHammer: return wsHammer;
2441 case wHookshot: return wsHookshotHead;
2442 case wHSHandle: return wsHookshotHandle;
2443 case wHSChain: return wsHookshotChainH;
2444 case wSSparkle: return wsSilverSparkle;
2445 case wFSparkle: return wsGoldSparkle;
2446 case wSmack: return wsHammerSmack;
2447 case wPhantom: return wsUnused45;
2448 case wCByrna: return wsByrnaCane;
2449 case wRefBeam: return wsRefBeam;
2450 case wStomp: return wsUnused45;
2451 case lwMax: return wsUnused45;
2452 case wScript1:
2453 case wScript2:
2454 case wScript3:
2455 case wScript4:
2456 case wScript5:
2457 case wScript6:
2458 case wScript7:
2459 case wScript8:
2460 case wScript9:
2461 case wScript10: return ws_0;
2462 case wIce: return wsIce; //new
2463 case wFlame: return wsEFire2; //new
2464 //not implemented; t/b/a
2465 case wSound:
2466 case wThrown:
2467 case wPot:
2468 case wLit:
2469 case wBombos:
2470 case wEther:
2471 case wQuake:
2472 case wSword180:
2473 case wSwordLA: return wsUnused45;
2474
2475 case ewFireball: return wsFireball2;
2476 case ewArrow: return wsEArrow;
2477 case ewBrang: return wsBrang;
2478 case ewSword: return wsEBeam;
2479 case ewRock: return wsRock;
2480 case ewMagic: return wsEMagic;
2481 case ewBomb: return wsEBomb;
2482 case ewSBomb: return wsESbomb;
2483 case ewLitBomb: return wsEBombblast;
2484 case ewLitSBomb: return wsESbombblast;
2485 case ewFireTrail: return wsEFiretrail;
2486 case ewFlame: return wsEFire;
2487 case ewWind: return wsEWind;
2488 case ewFlame2: return wsEFire2;
2489 case ewFlame2Trail: return wsEFiretrail2;
2490 case ewIce: return wsIce;
2491 case ewFireball2: return wsFireball2;
2492 default: return wsUnused45;
2493 }
2494 };
2495
2496 15079 static int32_t loadWeapon(const int32_t wid, const char * const funcvar)
2497 {
2498
1/2
✓ Branch 0 taken 15079 times.
✗ Branch 1 not taken.
15079 if ( !wid )
2499 {
2500 //can never be zero?
2501 Z_scripterrlog("The lweapon pointer used for %s is NULL or uninitialised.", funcvar);
2502 return _InvalidSpriteUID;
2503 }
2504 15079 tempweapon = (weapon *) Lwpns.getByUID(wid);
2505
2506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15079 times.
15079 if(tempweapon == NULL)
2507 {
2508 Z_scripterrlog("Invalid lweapon with UID %ld passed to %s\nLWeapons on screen have UIDs ", wid, funcvar);
2509
2510 for(word i = 0; i < Lwpns.Count(); i++)
2511 Z_scripterrlog("%ld ", Lwpns.spr(i)->getUID());
2512
2513 Z_scripterrlog("\n");
2514 return _InvalidSpriteUID;
2515 }
2516
2517 15079 return _NoError;
2518 15079 }
2519
2520 373740 static int32_t getLWeaponIndex(const int32_t lwid)
2521 {
2522
1/2
✓ Branch 0 taken 4154594 times.
✗ Branch 1 not taken.
4154594 for(word i = 0; i < Lwpns.Count(); i++)
2523 {
2524
2/2
✓ Branch 0 taken 373740 times.
✓ Branch 1 taken 3780854 times.
4154594 if(Lwpns.spr(i)->getUID() == lwid)
2525 373740 return i;
2526 3780854 }
2527
2528 return -1;
2529 373740 }
2530
2531 15079 static INLINE weapon *getWeapon()
2532 {
2533 15079 return tempweapon;
2534 }
2535
2536 16355 static INLINE void clearTemp()
2537 {
2538 16355 tempweapon = NULL;
2539 16355 }
2540
2541 private:
2542
2543 static weapon *tempweapon;
2544 };
2545
2546 weapon *LwpnH::tempweapon = NULL;
2547
2548 //EWeapon Helper
2549 class EwpnH : public SH
2550 {
2551
2552 public:
2553
2554 defWpnSprite getDefWeaponSprite(weapon *wp)
2555 {
2556 switch(wp->id)
2557 {
2558 case wNone: return ws_0;
2559 case wSword: return ws_0;
2560 case wBeam: return wsBeam;
2561 case wBrang : return wsBrang;
2562 case wBomb: return wsBomb;
2563 case wSBomb: return wsSBomb;
2564 case wLitBomb: return wsBombblast;
2565 case wLitSBomb: return wsBombblast;
2566 case wArrow: return wsArrow;
2567 case wFire: return wsFire;
2568 case wWhistle: return wsUnused45;
2569 case wBait: return wsBait;
2570 case wWand: return wsWandHandle;
2571 case wMagic: return wsMagic;
2572 case wCatching: return wsUnused45;
2573 case wWind: return wsWind;
2574 case wRefMagic: return wsRefMagic;
2575 case wRefFireball: return wsRefFireball;
2576 case wRefRock: return wsRock;
2577 case wHammer: return wsHammer;
2578 case wHookshot: return wsHookshotHead;
2579 case wHSHandle: return wsHookshotHandle;
2580 case wHSChain: return wsHookshotChainH;
2581 case wSSparkle: return wsSilverSparkle;
2582 case wFSparkle: return wsGoldSparkle;
2583 case wSmack: return wsHammerSmack;
2584 case wPhantom: return wsUnused45;
2585 case wCByrna: return wsByrnaCane;
2586 case wRefBeam: return wsRefBeam;
2587 case wStomp: return wsUnused45;
2588 case lwMax: return wsUnused45;
2589 case wScript1:
2590 case wScript2:
2591 case wScript3:
2592 case wScript4:
2593 case wScript5:
2594 case wScript6:
2595 case wScript7:
2596 case wScript8:
2597 case wScript9:
2598 case wScript10: return ws_0;
2599 case wIce: return wsIce; //new
2600 case wFlame: return wsEFire2; //new
2601 //not implemented; t/b/a
2602 case wSound:
2603 case wThrown:
2604 case wPot:
2605 case wLit:
2606 case wBombos:
2607 case wEther:
2608 case wQuake:
2609 case wSword180:
2610 case wSwordLA: return wsUnused45;
2611
2612 case ewFireball: return wsFireball2;
2613 case ewArrow: return wsEArrow;
2614 case ewBrang: return wsBrang;
2615 case ewSword: return wsEBeam;
2616 case ewRock: return wsRock;
2617 case ewMagic: return wsEMagic;
2618 case ewBomb: return wsEBomb;
2619 case ewSBomb: return wsESbomb;
2620 case ewLitBomb: return wsEBombblast;
2621 case ewLitSBomb: return wsESbombblast;
2622 case ewFireTrail: return wsEFiretrail;
2623 case ewFlame: return wsEFire;
2624 case ewWind: return wsEWind;
2625 case ewFlame2: return wsEFire2;
2626 case ewFlame2Trail: return wsEFiretrail2;
2627 case ewIce: return wsIce;
2628 case ewFireball2: return wsFireball2;
2629 default: return wsUnused45;
2630 }
2631 };
2632
2633 132144 static int32_t loadWeapon(const int32_t wid, const char * const funcvar)
2634 {
2635
1/2
✓ Branch 0 taken 132144 times.
✗ Branch 1 not taken.
132144 if ( !wid )
2636 {
2637 //can never be zero?
2638 Z_scripterrlog("The eweapon pointer used for %s is NULL or uninitialised.", funcvar);
2639 return _InvalidSpriteUID;
2640 }
2641 132144 tempweapon = (weapon *) Ewpns.getByUID(wid);
2642
2643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132144 times.
132144 if(tempweapon == NULL)
2644 {
2645 Z_scripterrlog("Invalid eweapon with UID %ld passed to %s\nEWeapons on screen have UIDs ", wid, funcvar);
2646
2647 for(word i = 0; i < Ewpns.Count(); i++)
2648 Z_scripterrlog("%ld ", Ewpns.spr(i)->getUID());
2649
2650 Z_scripterrlog("\n");
2651 return _InvalidSpriteUID;
2652 }
2653
2654 132144 return _NoError;
2655 132144 }
2656
2657 119542 static int32_t getEWeaponIndex(const int32_t ewid)
2658 {
2659
1/2
✓ Branch 0 taken 490280 times.
✗ Branch 1 not taken.
490280 for(word i = 0; i < Ewpns.Count(); i++)
2660 {
2661
2/2
✓ Branch 0 taken 119542 times.
✓ Branch 1 taken 370738 times.
490280 if(Ewpns.spr(i)->getUID() == ewid)
2662 119542 return i;
2663 370738 }
2664
2665 return -1;
2666 119542 }
2667
2668 132144 static INLINE weapon *getWeapon()
2669 {
2670 132144 return tempweapon;
2671 }
2672
2673 16355 static INLINE void clearTemp()
2674 {
2675 16355 tempweapon = NULL;
2676 16355 }
2677
2678 private:
2679
2680 static weapon *tempweapon;
2681 };
2682
2683 weapon *EwpnH::tempweapon = NULL;
2684
2685 16355 void clearScriptHelperData()
2686 {
2687 16355 GuyH::clearTemp();
2688 16355 ItemH::clearTemp();
2689 16355 LwpnH::clearTemp();
2690 16355 EwpnH::clearTemp();
2691 16355 }
2692
2693 ///---------------------------------------------//
2694 // Array Helper Functions //
2695 ///---------------------------------------------//
2696
2697 #define ZCARRAY_MAX_SIZE 214748
2698 class ArrayManager
2699 {
2700 public:
2701 ArrayManager(int32_t ptr, bool neg);
2702 ArrayManager(int32_t ptr);
2703
2704 int32_t get(int32_t indx) const;
2705 void set(int32_t indx, int32_t val);
2706 int32_t size() const;
2707
2708 bool resize(size_t newsize);
2709 bool resize_min(size_t minsz);
2710 bool can_resize();
2711 bool push(int32_t val, int indx = -1);
2712 int32_t pop(int indx = -1);
2713
2714 2013562 bool invalid() const {return _invalid;}
2715 bool internal() const {return !_invalid && !aptr;}
2716
2717 std::string asString(std::function<char const*(int32_t)> formatter, const size_t& limit) const;
2718
2719 bool negAccess;
2720 private:
2721 int32_t ptr;
2722 ZScriptArray* aptr;
2723 bool _invalid;
2724 };
2725
2726 //Array Helper
2727 class ArrayH : public SH
2728 {
2729 public:
2730 294114413 static size_t getSize(const int32_t ptr)
2731 {
2732 294114413 ArrayManager am(ptr);
2733 294114413 return am.size();
2734 }
2735
2736 //Can't you get the std::string and then check its length?
2737 static int32_t strlen(const int32_t ptr)
2738 {
2739 ArrayManager am(ptr);
2740 if (am.invalid() || am.size() == 0)
2741 return -1;
2742
2743 word count;
2744 size_t sz = am.size();
2745 for(count = 0; BC::checkUserArrayIndex(count, sz) == _NoError
2746 && am.get(count) != '\0'; count++);
2747
2748 return count;
2749 }
2750
2751 //Returns values of a zscript array as an std::string.
2752 1712134 static void getString(const int32_t ptr, string &str, dword num_chars = ZSCRIPT_MAX_STRING_CHARS, dword offset = 0)
2753 {
2754 1712134 ArrayManager am(ptr);
2755
2756
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1712129 times.
1712134 if(am.invalid())
2757 {
2758 5 str.clear();
2759 5 return;
2760 }
2761
2762 1712129 str.clear();
2763 1712129 size_t sz = am.size();
2764
5/6
✓ Branch 0 taken 19859438 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1712129 times.
✓ Branch 3 taken 18147309 times.
✓ Branch 4 taken 1712129 times.
✓ Branch 5 taken 18147309 times.
19859438 for(word i = offset; BC::checkUserArrayIndex(i, sz) == _NoError && am.get(i) != '\0' && num_chars != 0; i++)
2765 {
2766 18147309 int32_t c = am.get(i) / 10000;
2767
1/2
✓ Branch 0 taken 18147309 times.
✗ Branch 1 not taken.
18147309 if(char(c) != c)
2768 {
2769 Z_scripterrlog("Illegal char value (%d) at position [%d] in string pointer %d\n", c, i, ptr);
2770 Z_scripterrlog("Value of invalid char will overflow.\n");
2771 }
2772 18147309 str += char(c);
2773 18147309 --num_chars;
2774 18147309 }
2775 1712134 }
2776
2777 //Used for issues where reading the ZScript array floods the console with errors 'Accessing array index [12] size of 12.
2778 //Happens with Quad3D and some other functions, and I have no clue why. -Z ( 28th April, 2019 )
2779 //Like getString but for an array of longs instead of chars. *(arrayPtr is not checked for validity)
2780 static void getValues2(const int32_t ptr, int32_t* arrayPtr, dword num_values, dword offset = 0) //a hack -Z
2781 {
2782 ArrayManager am(ptr);
2783
2784 if(am.invalid())
2785 return;
2786
2787 size_t sz = am.size();
2788 for(word i = offset; BC::checkUserArrayIndex(i, sz+1) == _NoError && num_values != 0; i++)
2789 {
2790 arrayPtr[i] = (am.get(i) / 10000);
2791 num_values--;
2792 }
2793 }
2794
2795 //Like getString but for an array of longs instead of chars. *(arrayPtr is not checked for validity)
2796 static void getValues(const int32_t ptr, int32_t* arrayPtr, dword num_values, dword offset = 0)
2797 {
2798 ArrayManager am(ptr);
2799
2800 if (am.invalid())
2801 return;
2802 size_t sz = am.size();
2803 for(word i = offset; num_values != 0 && BC::checkUserArrayIndex(i, sz) == _NoError; i++)
2804 {
2805 arrayPtr[i] = (am.get(i) / 10000);
2806 num_values--;
2807 }
2808 }
2809
2810 static void copyValues(const int32_t ptr, const int32_t ptr2, size_t num_values)
2811 {
2812 ArrayManager am1(ptr), am2(ptr2);
2813 if(am1.invalid() || am2.invalid())
2814 return;
2815 size_t sz = std::min(am1.size(),am2.size());
2816 for(word i = 0; (BC::checkUserArrayIndex(i, sz) == _NoError) && num_values != 0; i++)
2817 {
2818 am1.set(i,am2.get(i));
2819 num_values--;
2820 }
2821 }
2822 //Get element from array
2823 1046915938 static INLINE int32_t getElement(const int32_t ptr, int32_t offset,
2824 const bool neg = false)
2825 {
2826 1046915938 ArrayManager am(ptr,neg);
2827 1046915938 return am.get(offset);
2828 }
2829
2830 //Set element in array
2831 518684632 static INLINE void setElement(const int32_t ptr, int32_t offset,
2832 const int32_t value, const bool neg = false)
2833 {
2834 518684632 ArrayManager am(ptr,neg);
2835 518684632 am.set(offset,value);
2836 518684632 }
2837
2838 //Puts values of a zscript array into a client <type> array. returns 0 on success. Overloaded
2839 template <typename T>
2840 static int32_t getArray(const int32_t ptr, T *refArray)
2841 {
2842 return getArray(ptr, getSize(ptr), 0, 0, 0, refArray);
2843 }
2844
2845 template <typename T>
2846 static int32_t getArray(const int32_t ptr, const word size, T *refArray)
2847 {
2848 return getArray(ptr, size, 0, 0, 0, refArray);
2849 }
2850
2851 template <typename T>
2852 static int32_t getArray(const int32_t ptr, const word size, word userOffset, const word userStride, const word refArrayOffset, T *refArray)
2853 {
2854 ArrayManager am(ptr);
2855
2856 if (am.invalid())
2857 return _InvalidPointer;
2858
2859 word j = 0, k = userStride;
2860
2861 size_t sz = am.size();
2862 for(word i = 0; j < size; i++)
2863 {
2864 if(i >= sz)
2865 return _Overflow;
2866
2867 if(userOffset-- > 0)
2868 continue;
2869
2870 if(k > 0)
2871 k--;
2872 else if(BC::checkUserArrayIndex(i, sz) == _NoError)
2873 {
2874 refArray[j + refArrayOffset] = T(am.get(i));
2875 k = userStride;
2876 j++;
2877 }
2878 }
2879
2880 return _NoError;
2881 }
2882
2883 265856 static int32_t setArray(const int32_t ptr, string const& s2, bool resize = false)
2884 {
2885 265856 ArrayManager am(ptr);
2886
2887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 265856 times.
265856 if (am.invalid())
2888 return _InvalidPointer;
2889
2890 word i;
2891
2892
3/4
✓ Branch 0 taken 265856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 254211 times.
✓ Branch 3 taken 11645 times.
265856 if(am.can_resize() && resize)
2893 11645 am.resize_min(s2.size()+1);
2894
2895 265856 size_t sz = am.size();
2896
2/2
✓ Branch 0 taken 5642234 times.
✓ Branch 1 taken 265808 times.
5908042 for(i = 0; i < s2.size(); i++)
2897 {
2898
2/2
✓ Branch 0 taken 5642186 times.
✓ Branch 1 taken 48 times.
5642234 if(i >= sz)
2899 {
2900 48 am.set(sz-1,'\0');
2901 48 return _Overflow;
2902 }
2903
2904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5642186 times.
5642186 if(BC::checkUserArrayIndex(i, sz) == _NoError)
2905 5642186 am.set(i,s2[i] * 10000);
2906 5642186 }
2907
2908
1/2
✓ Branch 0 taken 265808 times.
✗ Branch 1 not taken.
265808 if(BC::checkUserArrayIndex(i, sz) == _NoError)
2909 265808 am.set(i,'\0');
2910
2911 265808 return _NoError;
2912 265856 }
2913
2914 //Puts values of a client <type> array into a zscript array. returns 0 on success. Overloaded
2915 template <typename T>
2916 333 static int32_t setArray(const int32_t ptr, const word size, T *refArray, bool x10k = true, bool resize = false)
2917 {
2918 333 return setArray(ptr, size, 0, 0, 0, refArray, x10k, resize);
2919 }
2920
2921 template <typename T>
2922 333 static int32_t setArray(const int32_t ptr, const word size, word userOffset, const word userStride, const word refArrayOffset, T *refArray, bool x10k = true, bool resize = false)
2923 {
2924 333 ArrayManager am(ptr);
2925
2926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 333 times.
333 if (am.invalid())
2927 return _InvalidPointer;
2928
2929
2/4
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 333 times.
✗ Branch 3 not taken.
333 if(am.can_resize() && resize)
2930 am.resize_min((userStride+1)*size);
2931
2932 333 word j = 0, k = userStride;
2933 333 size_t sz = am.size();
2934
2/2
✓ Branch 0 taken 1757 times.
✓ Branch 1 taken 333 times.
2090 for(word i = 0; j < size; i++)
2935 {
2936
1/2
✓ Branch 0 taken 1757 times.
✗ Branch 1 not taken.
1757 if(i >= sz)
2937 return _Overflow; //Resize?
2938
2939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1757 times.
1757 if (userOffset > 0)
2940 {
2941 --userOffset;
2942 continue;
2943 }
2944
2945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1757 times.
1757 if(k > 0)
2946 k--;
2947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1757 times.
1757 else if(BC::checkUserArrayIndex(i, sz) == _NoError)
2948 {
2949 1757 am.set(i,int32_t(refArray[j + refArrayOffset]) * (x10k ? 10000 : 1));
2950 1757 k = userStride;
2951 1757 j++;
2952 1757 }
2953 1757 }
2954
2955 333 return _NoError;
2956 333 }
2957 };
2958
2959 1861728545 ArrayManager::ArrayManager(int32_t ptr, bool neg) : negAccess(neg), ptr(ptr)
2960 {
2961 1861728545 _invalid = false;
2962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1861728545 times.
1861728545 if(ptr >= INTARR_OFFS)
2963 {
2964 aptr = nullptr;
2965 if(sz_int_arr(ptr) < 0)
2966 _invalid = true;
2967 }
2968
2/2
✓ Branch 0 taken 1861727902 times.
✓ Branch 1 taken 643 times.
1861728545 else if(ptr == 0)
2969 {
2970 643 aptr = &INVALIDARRAY;
2971 643 _invalid = true;
2972 643 }
2973
1/2
✓ Branch 0 taken 1861727902 times.
✗ Branch 1 not taken.
1861727902 else if(ptr < 0) //An object array?
2974 {
2975 int32_t objptr = -ptr;
2976 auto it = objectRAM.find(objptr);
2977 if(it == objectRAM.end())
2978 {
2979 aptr = &INVALIDARRAY;
2980 _invalid = true;
2981 }
2982 else aptr = &(it->second);
2983 }
2984
2/2
✓ Branch 0 taken 1601051774 times.
✓ Branch 1 taken 260676128 times.
1861727902 else if(ptr >= NUM_ZSCRIPT_ARRAYS) //Then it's a global
2985 {
2986 1601051774 dword gptr = ptr - NUM_ZSCRIPT_ARRAYS;
2987
2988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1601051774 times.
1601051774 if(gptr > game->globalRAM.size())
2989 {
2990 aptr = &INVALIDARRAY;
2991 _invalid = true;
2992 }
2993 1601051774 else aptr = &(game->globalRAM[gptr]);
2994 1601051774 }
2995 else
2996 {
2997
1/2
✓ Branch 0 taken 260676128 times.
✗ Branch 1 not taken.
260676128 if(!localRAM[ptr].Valid())
2998 {
2999 aptr = &INVALIDARRAY;
3000 _invalid = true;
3001 }
3002 260676128 else aptr = &(localRAM[ptr]);
3003 }
3004
2/2
✓ Branch 0 taken 1861727902 times.
✓ Branch 1 taken 643 times.
1861728545 if(_invalid)
3005 {
3006 643 Z_scripterrlog("Invalid pointer (%i) passed to array "
3007 643 "(don't change the values of your array pointers)\n", ptr);
3008 643 }
3009 1861728545 }
3010 296127975 ArrayManager::ArrayManager(int32_t ptr) : ArrayManager(ptr,can_neg_array){}
3011
3012 1084922813 int32_t ArrayManager::get(int32_t indx) const
3013 {
3014
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 1084922648 times.
1084922813 if(_invalid) return -10000;
3015 1084922648 int32_t sz = size();
3016
1/2
✓ Branch 0 taken 1084922648 times.
✗ Branch 1 not taken.
1084922648 if(aptr)
3017 {
3018
2/2
✓ Branch 0 taken 1084289234 times.
✓ Branch 1 taken 633414 times.
1084922648 if(BC::checkUserArrayIndex(indx, sz, negAccess) == SH::_NoError)
3019 {
3020
1/2
✓ Branch 0 taken 1084289234 times.
✗ Branch 1 not taken.
1084289234 if(indx < 0)
3021 indx += sz; //[-1] becomes [size-1] -Em
3022 1084289234 return (*aptr)[indx];
3023 }
3024 633414 }
3025 else //internal special array
3026 {
3027 if(sz >= 0 && BC::checkUserArrayIndex(indx, sz, negAccess) == SH::_NoError)
3028 {
3029 if(indx < 0)
3030 indx += sz; //[-1] becomes [size-1] -Em
3031 return get_int_arr(ptr, indx);
3032 }
3033 }
3034 633414 return -10000;
3035 1084922813 }
3036 524594431 void ArrayManager::set(int32_t indx, int32_t val)
3037 {
3038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 524594431 times.
524594431 if(_invalid) return;
3039 524594431 int32_t sz = size();
3040
1/2
✓ Branch 0 taken 524594431 times.
✗ Branch 1 not taken.
524594431 if(aptr)
3041 {
3042
2/2
✓ Branch 0 taken 524587726 times.
✓ Branch 1 taken 6705 times.
524594431 if(BC::checkUserArrayIndex(indx, sz, negAccess) == SH::_NoError)
3043 {
3044
1/2
✓ Branch 0 taken 524587726 times.
✗ Branch 1 not taken.
524587726 if(indx < 0)
3045 indx += sz; //[-1] becomes [size-1] -Em
3046 524587726 (*aptr)[indx] = val;
3047 524587726 }
3048 524594431 }
3049 else //internal special array
3050 {
3051 if(sz >= 0 && BC::checkUserArrayIndex(indx, sz, negAccess) == SH::_NoError)
3052 {
3053 if(indx < 0)
3054 indx += sz; //[-1] becomes [size-1] -Em
3055 set_int_arr(ptr, indx, val);
3056 }
3057 }
3058 524594431 }
3059 1905621471 int32_t ArrayManager::size() const
3060 {
3061
2/2
✓ Branch 0 taken 473 times.
✓ Branch 1 taken 1905620998 times.
1905621471 if(_invalid) return -1;
3062
1/2
✓ Branch 0 taken 1905620998 times.
✗ Branch 1 not taken.
1905620998 if(aptr)
3063 1905620998 return aptr->Size();
3064 else // Internal special
3065 {
3066 int32_t sz = sz_int_arr(ptr);
3067 if(sz < 0)
3068 return -1;
3069 return sz;
3070 }
3071 1905621471 }
3072
3073 bool ArrayManager::resize(size_t newsize)
3074 {
3075 if(_invalid) return false;
3076 if(!aptr)
3077 {
3078 Z_scripterrlog("Special internal array '%d' not valid for operation 'Resize'\n", ptr);
3079 return false;
3080 }
3081 aptr->Resize(newsize);
3082 return true;
3083 }
3084 11645 bool ArrayManager::resize_min(size_t newsize)
3085 {
3086
1/2
✓ Branch 0 taken 11645 times.
✗ Branch 1 not taken.
11645 if(size() >= newsize)
3087 11645 return true;
3088 return resize(newsize);
3089 11645 }
3090 266189 bool ArrayManager::can_resize()
3091 {
3092
2/4
✓ Branch 0 taken 266189 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 266189 times.
✗ Branch 3 not taken.
266189 if(_invalid || !aptr)
3093 return false;
3094 266189 return true;
3095 266189 }
3096
3097 bool ArrayManager::push(int32_t val, int indx)
3098 {
3099 if(_invalid) return false;
3100 if(!aptr)
3101 {
3102 Z_scripterrlog("Special internal array '%d' not valid for operation 'Push'\n", ptr);
3103 return false;
3104 }
3105 if(aptr->Size() == ZCARRAY_MAX_SIZE)
3106 return false;
3107 aptr->Push(val,indx);
3108 return true;
3109 }
3110 int32_t ArrayManager::pop(int indx)
3111 {
3112 if(_invalid) return -10000;
3113 if(!aptr)
3114 {
3115 Z_scripterrlog("Special internal array '%d' not valid for operation 'Push'\n", ptr);
3116 return -10000;
3117 }
3118 if(aptr->Empty())
3119 {
3120 Z_scripterrlog("Array %d had nothing to Pop!\n",ptr);
3121 return -10000;
3122 }
3123 return aptr->Pop(indx);
3124 }
3125
3126 std::string ArrayManager::asString(std::function<char const*(int32_t)> formatter, const size_t& limit) const
3127 {
3128 if(_invalid) return "{ INVALID ARRAY }";
3129 std::ostringstream oss;
3130 oss << "{ ";
3131 size_t s = size();
3132 bool overflow = limit < s;
3133 if(overflow)
3134 s = limit;
3135
3136 for(auto q = 0; q < s; ++q)
3137 {
3138 oss << formatter(get(q));
3139 if (q + 1 < s)
3140 oss << ", ";
3141 }
3142 if (overflow)
3143 oss << ", ...";
3144 oss << " }";
3145 return oss.str();
3146 }
3147
3148 // Called to deallocate arrays when a script stops running
3149 24495 void deallocateArray(const int32_t ptrval)
3150 {
3151
1/2
✓ Branch 0 taken 24495 times.
✗ Branch 1 not taken.
24495 if(ptrval == 0) return;
3152
2/4
✓ Branch 0 taken 24495 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24495 times.
24495 if(ptrval==0 || ptrval >= NUM_ZSCRIPT_ARRAYS)
3153 Z_scripterrlog("Script tried to deallocate memory at invalid address %ld\n", ptrval);
3154
1/2
✓ Branch 0 taken 24495 times.
✗ Branch 1 not taken.
24495 else if(ptrval<0)
3155 Z_scripterrlog("Script tried to deallocate memory at object-based address %ld\n", ptrval);
3156 else
3157 {
3158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24495 times.
24495 if(arrayOwner[ptrval].specOwned) return; //ignore this deallocation
3159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24495 times.
24495 if(arrayOwner[ptrval].specCleared) return;
3160 24495 arrayOwner[ptrval].clear();
3161
3162
1/2
✓ Branch 0 taken 24495 times.
✗ Branch 1 not taken.
24495 if(!localRAM[ptrval].Valid())
3163 Z_scripterrlog("Script tried to deallocate memory that was not allocated at address %ld\n", ptrval);
3164 else
3165 24495 localRAM[ptrval].Clear();
3166 }
3167 24495 }
3168
3169 23319463 void FFScript::deallocateAllScriptOwned(ScriptType scriptType, const int32_t UID, bool requireAlways)
3170 {
3171
2/2
✓ Branch 0 taken 5806546287 times.
✓ Branch 1 taken 23319463 times.
5829865750 for(int32_t q = MIN_USER_BITMAPS; q < MAX_USER_BITMAPS; ++q)
3172 {
3173 5806546287 scb.script_created_bitmaps[q].own_clear(scriptType, UID);
3174 5806546287 }
3175
2/2
✓ Branch 0 taken 5969782528 times.
✓ Branch 1 taken 23319463 times.
5993101991 for(int32_t q = 0; q < MAX_USER_RNGS; ++q)
3176 {
3177 5969782528 script_rngs[q].own_clear(scriptType, UID);
3178 5969782528 }
3179
2/2
✓ Branch 0 taken 5969782528 times.
✓ Branch 1 taken 23319463 times.
5993101991 for (int32_t q = 0; q < MAX_USER_PALDATAS; ++q)
3180 {
3181 5969782528 script_paldatas[q].own_clear(scriptType, UID);
3182 5969782528 }
3183
2/2
✓ Branch 0 taken 5969782528 times.
✓ Branch 1 taken 23319463 times.
5993101991 for(int32_t q = 0; q < MAX_USER_FILES; ++q)
3184 {
3185 5969782528 script_files[q].own_clear(scriptType, UID);
3186 5969782528 }
3187
2/2
✓ Branch 0 taken 5969782528 times.
✓ Branch 1 taken 23319463 times.
5993101991 for(int32_t q = 0; q < MAX_USER_DIRS; ++q)
3188 {
3189 5969782528 script_dirs[q].own_clear(scriptType, UID);
3190 5969782528 }
3191
2/2
✓ Branch 0 taken 5969782528 times.
✓ Branch 1 taken 23319463 times.
5993101991 for(int32_t q = 0; q < MAX_USER_STACKS; ++q)
3192 {
3193 5969782528 script_stacks[q].own_clear(scriptType, UID);
3194 5969782528 }
3195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23319463 times.
23319463 for(int32_t q = 0; q < max_valid_object; ++q)
3196 {
3197 script_objects[q].own_clear(scriptType, UID);
3198 }
3199
4/4
✓ Branch 0 taken 21234103 times.
✓ Branch 1 taken 2085360 times.
✓ Branch 2 taken 672653 times.
✓ Branch 3 taken 20561450 times.
23319463 if(requireAlways && !get_qr(qr_ALWAYS_DEALLOCATE_ARRAYS))
3200 {
3201 //Keep 2.50.2 behavior if QR unchecked.
3202
2/2
✓ Branch 0 taken 20542801 times.
✓ Branch 1 taken 18649 times.
20561450 switch(scriptType)
3203 {
3204 case ScriptType::FFC:
3205 case ScriptType::Item:
3206 case ScriptType::Global:
3207 18649 return;
3208 }
3209 20542801 }
3210 //Z_eventlog("Attempting array deallocation from %s UID %d\n", script_types[scriptType], UID);
3211
2/2
✓ Branch 0 taken 23300814 times.
✓ Branch 1 taken 95416833330 times.
95440134144 for(int32_t i = 1; i < NUM_ZSCRIPT_ARRAYS; i++)
3212 {
3213
2/2
✓ Branch 0 taken 95416811808 times.
✓ Branch 1 taken 21522 times.
95416833330 if(arrayOwner[i].own_clear(scriptType,UID))
3214 21522 deallocateArray(i);
3215 95416833330 }
3216 23319463 }
3217
3218 105 void FFScript::deallocateAllScriptOwned()
3219 {
3220
2/2
✓ Branch 0 taken 26145 times.
✓ Branch 1 taken 105 times.
26250 for(int32_t q = MIN_USER_BITMAPS; q < MAX_USER_BITMAPS; ++q)
3221 {
3222 26145 scb.script_created_bitmaps[q].own_clear_any();
3223 26145 }
3224
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 105 times.
26985 for(int32_t q = 0; q < MAX_USER_RNGS; ++q)
3225 {
3226 26880 script_rngs[q].own_clear_any();
3227 26880 }
3228
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 105 times.
26985 for (int32_t q = 0; q < MAX_USER_PALDATAS; ++q)
3229 {
3230 26880 script_paldatas[q].own_clear_any();
3231 26880 }
3232
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 105 times.
26985 for(int32_t q = 0; q < MAX_USER_FILES; ++q)
3233 {
3234 26880 script_files[q].own_clear_any();
3235 26880 }
3236
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 105 times.
26985 for(int32_t q = 0; q < MAX_USER_DIRS; ++q)
3237 {
3238 26880 script_dirs[q].own_clear_any();
3239 26880 }
3240
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 105 times.
26985 for(int32_t q = 0; q < MAX_USER_STACKS; ++q)
3241 {
3242 26880 script_stacks[q].own_clear_any();
3243 26880 }
3244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 for(int32_t q = 0; q < max_valid_object; ++q)
3245 {
3246 script_objects[q].own_clear_any();
3247 }
3248 //No QR check here- always deallocate on quest exit.
3249
2/2
✓ Branch 0 taken 429975 times.
✓ Branch 1 taken 105 times.
430080 for(int32_t i = 1; i < NUM_ZSCRIPT_ARRAYS; i++)
3250 {
3251
2/2
✓ Branch 0 taken 429944 times.
✓ Branch 1 taken 31 times.
429975 if(localRAM[i].Valid())
3252 {
3253 // Unowned arrays are ALSO deallocated!
3254 31 arrayOwner[i].clear();
3255 31 deallocateArray(i);
3256 31 }
3257 429975 }
3258 105 }
3259
3260 287 void FFScript::deallocateAllScriptOwnedCont()
3261 {
3262
2/2
✓ Branch 0 taken 71463 times.
✓ Branch 1 taken 287 times.
71750 for(int32_t q = MIN_USER_BITMAPS; q < MAX_USER_BITMAPS; ++q)
3263 {
3264 71463 scb.script_created_bitmaps[q].own_clear_cont();
3265 71463 }
3266
2/2
✓ Branch 0 taken 73472 times.
✓ Branch 1 taken 287 times.
73759 for(int32_t q = 0; q < MAX_USER_RNGS; ++q)
3267 {
3268 73472 script_rngs[q].own_clear_cont();
3269 73472 }
3270
2/2
✓ Branch 0 taken 73472 times.
✓ Branch 1 taken 287 times.
73759 for (int32_t q = 0; q < MAX_USER_PALDATAS; ++q)
3271 {
3272 73472 script_paldatas[q].own_clear_cont();
3273 73472 }
3274
2/2
✓ Branch 0 taken 73472 times.
✓ Branch 1 taken 287 times.
73759 for(int32_t q = 0; q < MAX_USER_FILES; ++q)
3275 {
3276 73472 script_files[q].own_clear_cont();
3277 73472 }
3278
2/2
✓ Branch 0 taken 73472 times.
✓ Branch 1 taken 287 times.
73759 for(int32_t q = 0; q < MAX_USER_DIRS; ++q)
3279 {
3280 73472 script_dirs[q].own_clear_cont();
3281 73472 }
3282
2/2
✓ Branch 0 taken 73472 times.
✓ Branch 1 taken 287 times.
73759 for(int32_t q = 0; q < MAX_USER_STACKS; ++q)
3283 {
3284 73472 script_stacks[q].own_clear_cont();
3285 73472 }
3286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
287 for(int32_t q = 0; q < max_valid_object; ++q)
3287 {
3288 script_objects[q].own_clear_cont();
3289 }
3290 //No QR check here- always deallocate on quest exit.
3291
2/2
✓ Branch 0 taken 1175265 times.
✓ Branch 1 taken 287 times.
1175552 for(int32_t i = 1; i < NUM_ZSCRIPT_ARRAYS; i++)
3292 {
3293
2/2
✓ Branch 0 taken 1172323 times.
✓ Branch 1 taken 2942 times.
1175265 if(localRAM[i].Valid())
3294 {
3295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2942 times.
2942 if(arrayOwner[i].own_clear_cont())
3296 2942 deallocateArray(i);
3297 2942 }
3298 1175265 }
3299 287 }
3300
3301 409929 item *checkItem(int32_t iid)
3302 {
3303 409929 item *s = (item *)items.getByUID(iid);
3304
3305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 409929 times.
409929 if(s == NULL)
3306 {
3307 Z_eventlog("Script attempted to reference a nonexistent item!\n");
3308 Z_eventlog("You were trying to reference an item with UID = %ld; Items on screen are UIDs ", iid);
3309
3310 for(int32_t i=0; i<items.Count(); i++)
3311 {
3312 Z_eventlog("%ld ", items.spr(i)->getUID());
3313 }
3314
3315 Z_eventlog("\n");
3316 return NULL;
3317 }
3318
3319 409929 return s;
3320 409929 }
3321
3322 10101294 weapon *checkLWpn(int32_t eid, const char *what)
3323 {
3324 10101294 weapon *s = (weapon *)Lwpns.getByUID(eid);
3325
2/2
✓ Branch 0 taken 9984849 times.
✓ Branch 1 taken 116445 times.
10101294 if(s == NULL) //check lifted weapon
3326 {
3327 116445 weapon* lw = Hero.lift_wpn;
3328
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 116445 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
116445 if(lw && lw->getUID() == eid)
3329 s = lw;
3330 116445 }
3331
2/2
✓ Branch 0 taken 9984849 times.
✓ Branch 1 taken 116445 times.
10101294 if(s == NULL)
3332 {
3333
3334 116445 Z_eventlog("Script attempted to reference a nonexistent LWeapon!\n");
3335 116445 Z_eventlog("You were trying to reference the %s of an LWeapon with UID = %ld; LWeapons on screen are UIDs ", what, eid);
3336
3337
2/2
✓ Branch 0 taken 71278 times.
✓ Branch 1 taken 116445 times.
187723 for(int32_t i=0; i<Lwpns.Count(); i++)
3338 {
3339 71278 Z_eventlog("%ld ", Lwpns.spr(i)->getUID());
3340 71278 }
3341
3342 116445 Z_eventlog("\n");
3343 116445 return NULL;
3344 }
3345
3346 9984849 return s;
3347 10101294 }
3348
3349 23422487 weapon *checkEWpn(int32_t eid, const char *what)
3350 {
3351 23422487 weapon *s = (weapon *)Ewpns.getByUID(eid);
3352
3353
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 23422483 times.
23422487 if(s == NULL)
3354 {
3355
3356 4 Z_eventlog("Script attempted to reference a nonexistent EWeapon!\n");
3357 4 Z_eventlog("You were trying to reference the %s of an EWeapon with UID = %ld; EWeapons on screen are UIDs ", what, eid);
3358
3359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 for(int32_t i=0; i<Ewpns.Count(); i++)
3360 {
3361 Z_eventlog("%ld ", Ewpns.spr(i)->getUID());
3362 }
3363
3364 4 Z_eventlog("\n");
3365 4 return NULL;
3366 }
3367
3368 23422483 return s;
3369 23422487 }
3370
3371 286 user_file *checkFile(int32_t ref, const char *what, bool req_file = false, bool skipError = false)
3372 {
3373
3/4
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 284 times.
286 if(ref > 0 && ref <= MAX_USER_FILES)
3374 {
3375 284 user_file* f = &script_files[ref-1];
3376
1/2
✓ Branch 0 taken 284 times.
✗ Branch 1 not taken.
284 if(f->reserved)
3377 {
3378
3/4
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 280 times.
284 if(req_file && !f->file)
3379 {
3380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280 times.
280 if(skipError) return NULL;
3381 280 Z_scripterrlog("Script attempted to reference an invalid file!\n");
3382 280 Z_scripterrlog("File with UID = %ld does not have an open file connection!\n",ref);
3383 280 Z_scripterrlog("Use '->Open()' or '->Create()' to hook to a system file.\n");
3384 280 return NULL;
3385 }
3386 4 return f;
3387 }
3388 }
3389
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(skipError) return NULL;
3390 Z_scripterrlog("Script attempted to reference a nonexistent File!\n");
3391 if(what)
3392 Z_scripterrlog("You were trying to reference the '%s' of a File with UID = %ld\n", what, ref);
3393 else
3394 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3395 return NULL;
3396 286 }
3397
3398 user_object *checkObject(int32_t ref, bool skipError = false)
3399 {
3400 if(ref > 0 && ref < MAX_USER_OBJECTS)
3401 {
3402 user_object* obj = &script_objects[ref-1];
3403 if(obj->reserved)
3404 {
3405 return obj;
3406 }
3407 }
3408 if(skipError) return NULL;
3409 Z_scripterrlog("Script attempted to reference a nonexistent object!\n");
3410 Z_scripterrlog("You were trying to reference an object with UID = %ld\n", ref);
3411 return NULL;
3412 }
3413
3414 132 user_genscript *checkGenericScr(int32_t ref, const char *what)
3415 {
3416
2/4
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if(ref < 1 || ref >= NUMSCRIPTSGENERIC)
3417 {
3418 Z_scripterrlog("Invalid gendata pointer access (%ld) for '->%s'\n", ref, what);
3419 return NULL;
3420 }
3421 132 return &user_scripts[ref];
3422 132 }
3423 extern portal mirror_portal;
3424 portal *checkPortal(int32_t ref, const char *what, bool skiperr = false)
3425 {
3426 if(ref == -1)
3427 return &mirror_portal;
3428 portal* p = (portal*)portals.getByUID(ref);
3429 if(!p)
3430 {
3431 if(!skiperr)
3432 Z_scripterrlog("Invalid portal pointer access (%ld) for '->%s'\n", ref, what);
3433 return nullptr;
3434 }
3435 return p;
3436 }
3437
3438 savedportal *checkSavedPortal(int32_t ref, const char* what, bool skiperr = false)
3439 {
3440 savedportal* sp = game->getSavedPortal(ref);
3441 if(!sp)
3442 {
3443 if(!skiperr)
3444 Z_scripterrlog("Invalid savedportal pointer access (%ld) for '->%s'\n", ref, what);
3445 return nullptr;
3446 }
3447 return sp;
3448 }
3449 int32_t getPortalFromSaved(savedportal* p)
3450 {
3451 if(p == &(game->saved_mirror_portal))
3452 return -1;
3453 portal* prtl = nullptr;
3454 portals.forEach([&](sprite& spr)
3455 {
3456 portal* tmp = (portal*)&spr;
3457 if(p->getUID() == tmp->saved_data)
3458 {
3459 prtl = tmp;
3460 return true;
3461 }
3462 return false;
3463 });
3464 return prtl ? prtl->getUID() : 0;
3465 }
3466
3467 user_dir *checkDir(int32_t ref, const char *what, bool skipError = false)
3468 {
3469 if(ref > 0 && ref <= MAX_USER_DIRS)
3470 {
3471 user_dir* dr = &script_dirs[ref-1];
3472 if(dr->reserved)
3473 {
3474 return dr;
3475 }
3476 }
3477 if(skipError) return NULL;
3478 Z_scripterrlog("Script attempted to reference a nonexistent Directory!\n");
3479 if(what)
3480 Z_scripterrlog("You were trying to reference the '%s' of a Directory with UID = %ld\n", what, ref);
3481 else
3482 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3483 return NULL;
3484 }
3485
3486 user_stack *checkStack(int32_t ref, const char *what, bool skipError = false)
3487 {
3488 if(ref > 0 && ref <= USERSTACK_MAX_SIZE)
3489 {
3490 user_stack* st = &script_stacks[ref-1];
3491 if(st->reserved)
3492 {
3493 return st;
3494 }
3495 }
3496 if(skipError) return NULL;
3497 Z_scripterrlog("Script attempted to reference a nonexistent Stack!\n");
3498 if(what)
3499 Z_scripterrlog("You were trying to reference the '%s' of a Stack with UID = %ld\n", what, ref);
3500 else
3501 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3502 return NULL;
3503 }
3504
3505 303330 user_rng *checkRNG(int32_t ref, const char *what, bool skipError = false)
3506 {
3507
3/4
✓ Branch 0 taken 1523 times.
✓ Branch 1 taken 301807 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1523 times.
303330 if(ref > 0 && ref <= MAX_USER_RNGS)
3508 {
3509 1523 user_rng* rng = &script_rngs[ref-1];
3510
1/2
✓ Branch 0 taken 1523 times.
✗ Branch 1 not taken.
1523 if(rng->reserved)
3511 {
3512 1523 return rng;
3513 }
3514 }
3515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 301807 times.
301807 else if(!ref) //A null RNG pointer is special-case, access engine rng.
3516 {
3517 301807 return &nulrng;
3518 }
3519 if(skipError) return NULL;
3520 Z_scripterrlog("Script attempted to reference a nonexistent RNG!\n");
3521 if(what)
3522 Z_scripterrlog("You were trying to reference the '%s' of a RNG with UID = %ld\n", what, ref);
3523 else
3524 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3525 return NULL;
3526 303330 }
3527
3528 user_paldata* checkPalData(int32_t ref, const char* what, bool skipError = false)
3529 {
3530 if (ref > 0 && ref <= MAX_USER_PALDATAS)
3531 {
3532 user_paldata* pd = &script_paldatas[ref - 1];
3533 if (pd->reserved)
3534 {
3535 return pd;
3536 }
3537 }
3538 if (skipError) return NULL;
3539 Z_scripterrlog("Script attempted to reference a nonexistent paldata!\n");
3540 if(what)
3541 Z_scripterrlog("You were trying to reference the '%s' of a paldata with UID = %ld\n", what, ref);
3542 else
3543 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3544 return NULL;
3545 }
3546
3547 bottletype *checkBottleData(int32_t ref, const char *what, bool skipError = false)
3548 {
3549 if(ref > 0 && ref <= 64)
3550 {
3551 return &QMisc.bottle_types[ref-1];
3552 }
3553 if(skipError) return NULL;
3554 Z_scripterrlog("Script attempted to reference a nonexistent BottleData!\n");
3555 Z_scripterrlog("You were trying to reference the '%s' of a BottleData with UID = %ld\n", what, ref);
3556 return NULL;
3557 }
3558
3559 bottleshoptype *checkBottleShopData(int32_t ref, const char *what, bool skipError = false)
3560 {
3561 if(ref > 0 && ref <= 256)
3562 {
3563 return &QMisc.bottle_shop_types[ref-1];
3564 }
3565 if(skipError) return NULL;
3566 Z_scripterrlog("Script attempted to reference a nonexistent BottleShopData!\n");
3567 Z_scripterrlog("You were trying to reference the '%s' of a BottleShopData with UID = %ld\n", what, ref);
3568 return NULL;
3569 }
3570
3571 646718 user_bitmap *checkBitmap(int32_t ref, const char *what, bool req_valid = false, bool skipError = false)
3572 {
3573 646718 int32_t ind = ref - 10;
3574
2/4
✓ Branch 0 taken 646718 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 646718 times.
646718 if(ind >= firstUserGeneratedBitmap && ind < MAX_USER_BITMAPS)
3575 {
3576 646718 user_bitmap* b = &(scb.script_created_bitmaps[ind]);
3577
1/2
✓ Branch 0 taken 646718 times.
✗ Branch 1 not taken.
646718 if(b->reserved())
3578 {
3579
3/4
✓ Branch 0 taken 616532 times.
✓ Branch 1 taken 30186 times.
✓ Branch 2 taken 616532 times.
✗ Branch 3 not taken.
646718 if(req_valid && !b->u_bmp)
3580 {
3581 if(skipError) return NULL;
3582 Z_scripterrlog("Script attempted to reference an invalid bitmap!\n");
3583 Z_scripterrlog("Bitmap with UID = %ld does not have a valid memory bitmap!\n",ref);
3584 Z_scripterrlog("Use '->Create()' to create a memory bitmap.\n");
3585 return NULL;
3586 }
3587 646718 return b;
3588 }
3589 }
3590 else
3591 {
3592 switch(ind)
3593 {
3594 case rtSCREEN:
3595 case rtBMP0:
3596 case rtBMP1:
3597 case rtBMP2:
3598 case rtBMP3:
3599 case rtBMP4:
3600 case rtBMP5:
3601 case rtBMP6:
3602 zprint2("Internal error: 'checkBitmap()' recieved ref pointing to system bitmap!\n");
3603 zprint2("Please report this as a bug!\n");
3604 break;
3605 }
3606 }
3607 if(skipError) return NULL;
3608 Z_scripterrlog("Script attempted to reference a nonexistent bitmap!\n");
3609 if(what)
3610 Z_scripterrlog("You were trying to reference the '%s' of a bitmap with UID = %ld\n", what, ref);
3611 else
3612 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3613 return NULL;
3614 646718 }
3615
3616 extern const std::string subscr_names[sstMAX];
3617 ZCSubscreen *checkSubData(int32_t ref, const char *what, int req_ty = -1)
3618 {
3619 auto [ptr,ty] = load_subdata(ref);
3620 if(ptr)
3621 {
3622 if(req_ty < 0 || req_ty == ty)
3623 return ptr;
3624 else
3625 {
3626 Z_scripterrlog("Wrong type of SubscreenData accessed! Expecting type '%s', but found '%s'\n",
3627 subscr_names[req_ty].c_str(), subscr_names[ty].c_str());
3628 }
3629 }
3630 else Z_scripterrlog("Script attempted to reference a nonexistent SubscreenData!\n");
3631
3632 Z_scripterrlog("You were trying to reference the '%s' of a SubscreenData with UID = %ld\n", what, ref);
3633 return NULL;
3634 }
3635 SubscrPage *checkSubPage(int32_t ref, const char *what, int req_ty = -1)
3636 {
3637 auto [ptr,ty] = load_subpage(ref);
3638 if(ptr)
3639 {
3640 if(req_ty < 0 || req_ty == ty)
3641 return ptr;
3642 else
3643 {
3644 Z_scripterrlog("Wrong type of Subscreen accessed! Expecting type '%s', but found '%s'\n",
3645 subscr_names[req_ty].c_str(), subscr_names[ty].c_str());
3646 }
3647 }
3648 else Z_scripterrlog("Script attempted to reference a nonexistent SubscreenPage!\n");
3649
3650 Z_scripterrlog("You were trying to reference the '%s' of a SubscreenPage with UID = %ld\n", what, ref);
3651 return NULL;
3652 }
3653 SubscrWidget *checkSubWidg(int32_t ref, const char *what, int req_widg_ty = -1, int req_sub_ty = -1)
3654 {
3655 auto [ptr,ty] = load_subwidg(ref);
3656 if(ptr)
3657 {
3658 if(req_sub_ty < 0 || req_sub_ty == ty)
3659 {
3660 if(req_widg_ty < 0 || req_widg_ty == ptr->getType())
3661 return ptr;
3662 else
3663 {
3664 auto listdata = GUI::ZCListData::subscr_widgets();
3665 Z_scripterrlog("Wrong type of SubscreenWidget accessed! Expecting type '%s', but found '%s'\n",
3666 listdata.findText(req_widg_ty).c_str(), listdata.findText(ptr->getType()).c_str());
3667 }
3668 }
3669 else
3670 {
3671 Z_scripterrlog("Wrong type of Subscreen accessed! Expecting subscreen type '%s', but found '%s'\n",
3672 subscr_names[req_sub_ty].c_str(), subscr_names[ty].c_str());
3673 }
3674 }
3675 else Z_scripterrlog("Script attempted to reference a nonexistent SubscreenWidget!\n");
3676
3677 Z_scripterrlog("You were trying to reference the '%s' of a SubscreenWidget with UID = %ld\n", what, ref);
3678 return NULL;
3679 }
3680
3681 void bad_subwidg_type(string const& name, bool func, byte type)
3682 {
3683 Z_scripterrlog("Widget type %d '%s' does not have a '%s' %s!\n",
3684 type, subwidg_internal_names[type].c_str(), name.c_str(),
3685 func ? "function" : "value");
3686 }
3687
3688 int32_t get_screen_d(int32_t index1, int32_t index2)
3689 {
3690 if(index2 < 0 || index2 > 7)
3691 {
3692 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", index1);
3693 return 0;
3694 }
3695
3696 return game->screen_d[index1][index2];
3697 }
3698
3699 void set_screen_d(int32_t index1, int32_t index2, int32_t val)
3700 {
3701 if(index2 < 0 || index2 > 7)
3702 {
3703 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", index1);
3704 return;
3705 }
3706
3707 game->screen_d[index1][index2] = val;
3708 }
3709
3710 // If scr is currently being used as a layer, return that layer no.
3711 39845144 int32_t whichlayer(int32_t scr)
3712 {
3713
2/2
✓ Branch 0 taken 198687540 times.
✓ Branch 1 taken 28204008 times.
226891548 for(int32_t i = 0; i < 6; i++)
3714 {
3715
2/2
✓ Branch 0 taken 11641136 times.
✓ Branch 1 taken 187046404 times.
198687540 if(scr == (tmpscr->layermap[i] - 1) * MAPSCRS + tmpscr->layerscreen[i])
3716 11641136 return i;
3717 187046404 }
3718
3719 28204008 return -1;
3720 39845144 }
3721
3722 sprite *s;
3723
3724 int32_t item_flag(int32_t flag)
3725 {
3726 if(unsigned(ri->idata) >= MAXITEMS)
3727 {
3728 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
3729 return 0;
3730 }
3731 return (itemsbuf[ri->idata].flags & flag) ? 10000 : 0;
3732 }
3733 void item_flag(int32_t flag, bool val)
3734 {
3735 if(unsigned(ri->idata) >= MAXITEMS)
3736 {
3737 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
3738 return;
3739 }
3740 SETFLAG(itemsbuf[ri->idata].flags, flag, val);
3741 }
3742
3743 //Forward decl
3744 int32_t do_msgheight(int32_t msg, char const* str);
3745 int32_t do_msgwidth(int32_t msg, char const* str);
3746 //
3747
3748 int32_t earlyretval = -1;
3749 2767297062 int32_t get_register(const int32_t arg)
3750 {
3751 2767297062 int32_t ret = 0;
3752
3753 //Macros
3754
3755 #define GET_SPRITEDATA_VAR_INT(member, str) \
3756 { \
3757 if(unsigned(ri->spritesref) > (MAXWPNS-1) ) \
3758 { \
3759 ret = -10000; \
3760 Z_scripterrlog("Invalid Sprite ID passed to spritedata->%s: %d\n", str, (ri->spritesref*10000));\
3761 } \
3762 else \
3763 ret = (wpnsbuf[ri->spritesref].member * 10000); \
3764 }
3765
3766
357/1408
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1184834 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 7892558 times.
✓ Branch 6 taken 35 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 35 times.
✓ Branch 9 taken 2180472 times.
✓ Branch 10 taken 2596310 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1282 times.
✓ Branch 13 taken 641181 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 2112268 times.
✓ Branch 17 taken 44802009 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 801725 times.
✓ Branch 20 taken 557644 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 280566 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 6213788 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 206522 times.
✓ Branch 28 taken 206522 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 206547 times.
✓ Branch 33 taken 173466 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✓ Branch 36 taken 4636 times.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✓ Branch 45 taken 2 times.
✗ Branch 46 not taken.
✓ Branch 47 taken 19671 times.
✓ Branch 48 taken 12319 times.
✗ Branch 49 not taken.
✓ Branch 50 taken 9024 times.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✓ Branch 53 taken 88721 times.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✓ Branch 56 taken 561 times.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✓ Branch 67 taken 92884 times.
✓ Branch 68 taken 1334804 times.
✓ Branch 69 taken 847912 times.
✓ Branch 70 taken 1328070 times.
✓ Branch 71 taken 1370269 times.
✓ Branch 72 taken 5693944 times.
✓ Branch 73 taken 5182994 times.
✓ Branch 74 taken 3135646 times.
✓ Branch 75 taken 119289 times.
✓ Branch 76 taken 23391 times.
✓ Branch 77 taken 23391 times.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✓ Branch 81 taken 766680 times.
✓ Branch 82 taken 1041016 times.
✓ Branch 83 taken 776094 times.
✓ Branch 84 taken 557304 times.
✓ Branch 85 taken 514964 times.
✓ Branch 86 taken 873882 times.
✓ Branch 87 taken 873847 times.
✓ Branch 88 taken 541201 times.
✗ Branch 89 not taken.
✗ Branch 90 not taken.
✗ Branch 91 not taken.
✗ Branch 92 not taken.
✓ Branch 93 taken 3743 times.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✗ Branch 96 not taken.
✗ Branch 97 not taken.
✗ Branch 98 not taken.
✗ Branch 99 not taken.
✓ Branch 100 taken 4206 times.
✓ Branch 101 taken 5084 times.
✓ Branch 102 taken 114 times.
✗ Branch 103 not taken.
✗ Branch 104 not taken.
✗ Branch 105 not taken.
✓ Branch 106 taken 117090 times.
✓ Branch 107 taken 7933 times.
✗ Branch 108 not taken.
✗ Branch 109 not taken.
✗ Branch 110 not taken.
✗ Branch 111 not taken.
✗ Branch 112 not taken.
✓ Branch 113 taken 18 times.
✓ Branch 114 taken 7933 times.
✗ Branch 115 not taken.
✗ Branch 116 not taken.
✗ Branch 117 not taken.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✗ Branch 120 not taken.
✗ Branch 121 not taken.
✓ Branch 122 taken 6 times.
✓ Branch 123 taken 334 times.
✗ Branch 124 not taken.
✗ Branch 125 not taken.
✓ Branch 126 taken 1300 times.
✓ Branch 127 taken 1300 times.
✓ Branch 128 taken 685905 times.
✗ Branch 129 not taken.
✓ Branch 130 taken 19906 times.
✓ Branch 131 taken 108294 times.
✗ Branch 132 not taken.
✗ Branch 133 not taken.
✗ Branch 134 not taken.
✗ Branch 135 not taken.
✗ Branch 136 not taken.
✗ Branch 137 not taken.
✗ Branch 138 not taken.
✗ Branch 139 not taken.
✗ Branch 140 not taken.
✗ Branch 141 not taken.
✗ Branch 142 not taken.
✗ Branch 143 not taken.
✗ Branch 144 not taken.
✗ Branch 145 not taken.
✗ Branch 146 not taken.
✗ Branch 147 not taken.
✗ Branch 148 not taken.
✗ Branch 149 not taken.
✗ Branch 150 not taken.
✗ Branch 151 not taken.
✗ Branch 152 not taken.
✗ Branch 153 not taken.
✗ Branch 154 not taken.
✗ Branch 155 not taken.
✗ Branch 156 not taken.
✗ Branch 157 not taken.
✗ Branch 158 not taken.
✓ Branch 159 taken 713905 times.
✓ Branch 160 taken 709431 times.
✓ Branch 161 taken 55748 times.
✗ Branch 162 not taken.
✗ Branch 163 not taken.
✓ Branch 164 taken 67683 times.
✗ Branch 165 not taken.
✓ Branch 166 taken 1329 times.
✓ Branch 167 taken 2 times.
✗ Branch 168 not taken.
✗ Branch 169 not taken.
✗ Branch 170 not taken.
✗ Branch 171 not taken.
✓ Branch 172 taken 49794 times.
✗ Branch 173 not taken.
✓ Branch 174 taken 3289 times.
✗ Branch 175 not taken.
✗ Branch 176 not taken.
✓ Branch 177 taken 1094820 times.
✗ Branch 178 not taken.
✓ Branch 179 taken 135142 times.
✗ Branch 180 not taken.
✗ Branch 181 not taken.
✗ Branch 182 not taken.
✓ Branch 183 taken 135091 times.
✓ Branch 184 taken 27874 times.
✓ Branch 185 taken 25249 times.
✓ Branch 186 taken 1553638 times.
✓ Branch 187 taken 4320 times.
✗ Branch 188 not taken.
✗ Branch 189 not taken.
✗ Branch 190 not taken.
✓ Branch 191 taken 180 times.
✗ Branch 192 not taken.
✗ Branch 193 not taken.
✗ Branch 194 not taken.
✗ Branch 195 not taken.
✗ Branch 196 not taken.
✗ Branch 197 not taken.
✗ Branch 198 not taken.
✗ Branch 199 not taken.
✗ Branch 200 not taken.
✗ Branch 201 not taken.
✗ Branch 202 not taken.
✗ Branch 203 not taken.
✗ Branch 204 not taken.
✗ Branch 205 not taken.
✗ Branch 206 not taken.
✗ Branch 207 not taken.
✗ Branch 208 not taken.
✗ Branch 209 not taken.
✗ Branch 210 not taken.
✓ Branch 211 taken 1267145 times.
✗ Branch 212 not taken.
✓ Branch 213 taken 1266708 times.
✓ Branch 214 taken 63485 times.
✗ Branch 215 not taken.
✗ Branch 216 not taken.
✗ Branch 217 not taken.
✗ Branch 218 not taken.
✓ Branch 219 taken 362690 times.
✓ Branch 220 taken 373525 times.
✗ Branch 221 not taken.
✓ Branch 222 taken 68688 times.
✓ Branch 223 taken 90188 times.
✓ Branch 224 taken 2150394 times.
✓ Branch 225 taken 106032 times.
✗ Branch 226 not taken.
✓ Branch 227 taken 24909 times.
✗ Branch 228 not taken.
✗ Branch 229 not taken.
✗ Branch 230 not taken.
✓ Branch 231 taken 65540 times.
✓ Branch 232 taken 8 times.
✓ Branch 233 taken 96 times.
✗ Branch 234 not taken.
✗ Branch 235 not taken.
✗ Branch 236 not taken.
✗ Branch 237 not taken.
✓ Branch 238 taken 62523 times.
✓ Branch 239 taken 12470 times.
✓ Branch 240 taken 24497 times.
✓ Branch 241 taken 24497 times.
✗ Branch 242 not taken.
✗ Branch 243 not taken.
✗ Branch 244 not taken.
✗ Branch 245 not taken.
✗ Branch 246 not taken.
✗ Branch 247 not taken.
✓ Branch 248 taken 16680 times.
✗ Branch 249 not taken.
✗ Branch 250 not taken.
✗ Branch 251 not taken.
✗ Branch 252 not taken.
✗ Branch 253 not taken.
✗ Branch 254 not taken.
✗ Branch 255 not taken.
✗ Branch 256 not taken.
✗ Branch 257 not taken.
✗ Branch 258 not taken.
✗ Branch 259 not taken.
✗ Branch 260 not taken.
✗ Branch 261 not taken.
✗ Branch 262 not taken.
✗ Branch 263 not taken.
✗ Branch 264 not taken.
✗ Branch 265 not taken.
✗ Branch 266 not taken.
✗ Branch 267 not taken.
✗ Branch 268 not taken.
✗ Branch 269 not taken.
✓ Branch 270 taken 2103 times.
✗ Branch 271 not taken.
✗ Branch 272 not taken.
✓ Branch 273 taken 26 times.
✓ Branch 274 taken 972 times.
✓ Branch 275 taken 471 times.
✓ Branch 276 taken 1608203 times.
✓ Branch 277 taken 15 times.
✓ Branch 278 taken 856 times.
✗ Branch 279 not taken.
✓ Branch 280 taken 2369090 times.
✓ Branch 281 taken 561833 times.
✗ Branch 282 not taken.
✓ Branch 283 taken 225833 times.
✗ Branch 284 not taken.
✗ Branch 285 not taken.
✗ Branch 286 not taken.
✓ Branch 287 taken 22596069 times.
✓ Branch 288 taken 125 times.
✓ Branch 289 taken 63717 times.
✗ Branch 290 not taken.
✗ Branch 291 not taken.
✓ Branch 292 taken 49235831 times.
✗ Branch 293 not taken.
✗ Branch 294 not taken.
✗ Branch 295 not taken.
✗ Branch 296 not taken.
✗ Branch 297 not taken.
✗ Branch 298 not taken.
✓ Branch 299 taken 514 times.
✗ Branch 300 not taken.
✗ Branch 301 not taken.
✗ Branch 302 not taken.
✗ Branch 303 not taken.
✗ Branch 304 not taken.
✗ Branch 305 not taken.
✗ Branch 306 not taken.
✗ Branch 307 not taken.
✗ Branch 308 not taken.
✗ Branch 309 not taken.
✗ Branch 310 not taken.
✗ Branch 311 not taken.
✗ Branch 312 not taken.
✗ Branch 313 not taken.
✗ Branch 314 not taken.
✗ Branch 315 not taken.
✗ Branch 316 not taken.
✗ Branch 317 not taken.
✗ Branch 318 not taken.
✓ Branch 319 taken 1 times.
✗ Branch 320 not taken.
✗ Branch 321 not taken.
✓ Branch 322 taken 910 times.
✓ Branch 323 taken 43250 times.
✗ Branch 324 not taken.
✓ Branch 325 taken 3 times.
✗ Branch 326 not taken.
✗ Branch 327 not taken.
✗ Branch 328 not taken.
✗ Branch 329 not taken.
✗ Branch 330 not taken.
✗ Branch 331 not taken.
✗ Branch 332 not taken.
✗ Branch 333 not taken.
✗ Branch 334 not taken.
✗ Branch 335 not taken.
✗ Branch 336 not taken.
✓ Branch 337 taken 10246 times.
✓ Branch 338 taken 7214 times.
✓ Branch 339 taken 2272 times.
✓ Branch 340 taken 6641186 times.
✓ Branch 341 taken 1524194 times.
✓ Branch 342 taken 11321068 times.
✗ Branch 343 not taken.
✗ Branch 344 not taken.
✓ Branch 345 taken 1 times.
✗ Branch 346 not taken.
✗ Branch 347 not taken.
✗ Branch 348 not taken.
✗ Branch 349 not taken.
✓ Branch 350 taken 6554876 times.
✗ Branch 351 not taken.
✗ Branch 352 not taken.
✗ Branch 353 not taken.
✗ Branch 354 not taken.
✗ Branch 355 not taken.
✓ Branch 356 taken 213 times.
✗ Branch 357 not taken.
✓ Branch 358 taken 19 times.
✗ Branch 359 not taken.
✓ Branch 360 taken 1124 times.
✓ Branch 361 taken 734895 times.
✗ Branch 362 not taken.
✗ Branch 363 not taken.
✗ Branch 364 not taken.
✗ Branch 365 not taken.
✗ Branch 366 not taken.
✗ Branch 367 not taken.
✗ Branch 368 not taken.
✗ Branch 369 not taken.
✗ Branch 370 not taken.
✗ Branch 371 not taken.
✓ Branch 372 taken 22016 times.
✗ Branch 373 not taken.
✗ Branch 374 not taken.
✗ Branch 375 not taken.
✗ Branch 376 not taken.
✗ Branch 377 not taken.
✗ Branch 378 not taken.
✗ Branch 379 not taken.
✗ Branch 380 not taken.
✗ Branch 381 not taken.
✓ Branch 382 taken 15657 times.
✓ Branch 383 taken 158257 times.
✓ Branch 384 taken 2886839 times.
✓ Branch 385 taken 15646729 times.
✗ Branch 386 not taken.
✗ Branch 387 not taken.
✗ Branch 388 not taken.
✓ Branch 389 taken 802600 times.
✗ Branch 390 not taken.
✗ Branch 391 not taken.
✓ Branch 392 taken 427 times.
✗ Branch 393 not taken.
✗ Branch 394 not taken.
✗ Branch 395 not taken.
✗ Branch 396 not taken.
✗ Branch 397 not taken.
✗ Branch 398 not taken.
✗ Branch 399 not taken.
✗ Branch 400 not taken.
✗ Branch 401 not taken.
✗ Branch 402 not taken.
✗ Branch 403 not taken.
✗ Branch 404 not taken.
✗ Branch 405 not taken.
✗ Branch 406 not taken.
✗ Branch 407 not taken.
✗ Branch 408 not taken.
✗ Branch 409 not taken.
✗ Branch 410 not taken.
✗ Branch 411 not taken.
✗ Branch 412 not taken.
✗ Branch 413 not taken.
✗ Branch 414 not taken.
✗ Branch 415 not taken.
✗ Branch 416 not taken.
✗ Branch 417 not taken.
✗ Branch 418 not taken.
✗ Branch 419 not taken.
✗ Branch 420 not taken.
✗ Branch 421 not taken.
✗ Branch 422 not taken.
✗ Branch 423 not taken.
✗ Branch 424 not taken.
✗ Branch 425 not taken.
✗ Branch 426 not taken.
✗ Branch 427 not taken.
✗ Branch 428 not taken.
✗ Branch 429 not taken.
✗ Branch 430 not taken.
✗ Branch 431 not taken.
✗ Branch 432 not taken.
✗ Branch 433 not taken.
✗ Branch 434 not taken.
✗ Branch 435 not taken.
✗ Branch 436 not taken.
✗ Branch 437 not taken.
✗ Branch 438 not taken.
✗ Branch 439 not taken.
✗ Branch 440 not taken.
✗ Branch 441 not taken.
✗ Branch 442 not taken.
✗ Branch 443 not taken.
✗ Branch 444 not taken.
✗ Branch 445 not taken.
✗ Branch 446 not taken.
✗ Branch 447 not taken.
✗ Branch 448 not taken.
✗ Branch 449 not taken.
✗ Branch 450 not taken.
✗ Branch 451 not taken.
✗ Branch 452 not taken.
✗ Branch 453 not taken.
✗ Branch 454 not taken.
✗ Branch 455 not taken.
✗ Branch 456 not taken.
✗ Branch 457 not taken.
✗ Branch 458 not taken.
✗ Branch 459 not taken.
✗ Branch 460 not taken.
✗ Branch 461 not taken.
✗ Branch 462 not taken.
✗ Branch 463 not taken.
✗ Branch 464 not taken.
✗ Branch 465 not taken.
✗ Branch 466 not taken.
✗ Branch 467 not taken.
✗ Branch 468 not taken.
✗ Branch 469 not taken.
✗ Branch 470 not taken.
✗ Branch 471 not taken.
✗ Branch 472 not taken.
✗ Branch 473 not taken.
✗ Branch 474 not taken.
✗ Branch 475 not taken.
✗ Branch 476 not taken.
✗ Branch 477 not taken.
✗ Branch 478 not taken.
✓ Branch 479 taken 952310006 times.
✗ Branch 480 not taken.
✓ Branch 481 taken 751885248 times.
✗ Branch 482 not taken.
✓ Branch 483 taken 4440400 times.
✓ Branch 484 taken 468471069 times.
✓ Branch 485 taken 8343964 times.
✓ Branch 486 taken 35 times.
✓ Branch 487 taken 35 times.
✓ Branch 488 taken 103 times.
✓ Branch 489 taken 98 times.
✓ Branch 490 taken 2596581 times.
✓ Branch 491 taken 6076 times.
✓ Branch 492 taken 28819 times.
✓ Branch 493 taken 15045605 times.
✓ Branch 494 taken 14903591 times.
✓ Branch 495 taken 564437 times.
✗ Branch 496 not taken.
✓ Branch 497 taken 765420 times.
✓ Branch 498 taken 15444780 times.
✗ Branch 499 not taken.
✓ Branch 500 taken 655866 times.
✓ Branch 501 taken 552028 times.
✗ Branch 502 not taken.
✓ Branch 503 taken 17 times.
✓ Branch 504 taken 19615156 times.
✓ Branch 505 taken 5424 times.
✗ Branch 506 not taken.
✓ Branch 507 taken 623338 times.
✗ Branch 508 not taken.
✓ Branch 509 taken 481556 times.
✓ Branch 510 taken 2929 times.
✗ Branch 511 not taken.
✗ Branch 512 not taken.
✓ Branch 513 taken 2402 times.
✗ Branch 514 not taken.
✗ Branch 515 not taken.
✓ Branch 516 taken 206547 times.
✗ Branch 517 not taken.
✗ Branch 518 not taken.
✓ Branch 519 taken 20320 times.
✓ Branch 520 taken 13864 times.
✗ Branch 521 not taken.
✗ Branch 522 not taken.
✗ Branch 523 not taken.
✗ Branch 524 not taken.
✗ Branch 525 not taken.
✗ Branch 526 not taken.
✗ Branch 527 not taken.
✗ Branch 528 not taken.
✗ Branch 529 not taken.
✗ Branch 530 not taken.
✗ Branch 531 not taken.
✗ Branch 532 not taken.
✗ Branch 533 not taken.
✗ Branch 534 not taken.
✓ Branch 535 taken 4123 times.
✓ Branch 536 taken 3131387 times.
✓ Branch 537 taken 119580 times.
✗ Branch 538 not taken.
✓ Branch 539 taken 766680 times.
✗ Branch 540 not taken.
✓ Branch 541 taken 728101 times.
✓ Branch 542 taken 276546 times.
✓ Branch 543 taken 715737 times.
✓ Branch 544 taken 1875584 times.
✓ Branch 545 taken 1726419 times.
✓ Branch 546 taken 1861217 times.
✓ Branch 547 taken 1691656 times.
✓ Branch 548 taken 541201 times.
✓ Branch 549 taken 14 times.
✓ Branch 550 taken 213 times.
✗ Branch 551 not taken.
✓ Branch 552 taken 1121 times.
✓ Branch 553 taken 6774 times.
✗ Branch 554 not taken.
✗ Branch 555 not taken.
✗ Branch 556 not taken.
✓ Branch 557 taken 468 times.
✗ Branch 558 not taken.
✓ Branch 559 taken 5848 times.
✗ Branch 560 not taken.
✓ Branch 561 taken 24 times.
✗ Branch 562 not taken.
✗ Branch 563 not taken.
✗ Branch 564 not taken.
✓ Branch 565 taken 2552 times.
✗ Branch 566 not taken.
✓ Branch 567 taken 2552 times.
✗ Branch 568 not taken.
✓ Branch 569 taken 2552 times.
✓ Branch 570 taken 2552 times.
✓ Branch 571 taken 2542 times.
✗ Branch 572 not taken.
✗ Branch 573 not taken.
✗ Branch 574 not taken.
✗ Branch 575 not taken.
✗ Branch 576 not taken.
✗ Branch 577 not taken.
✗ Branch 578 not taken.
✗ Branch 579 not taken.
✗ Branch 580 not taken.
✗ Branch 581 not taken.
✗ Branch 582 not taken.
✗ Branch 583 not taken.
✗ Branch 584 not taken.
✗ Branch 585 not taken.
✗ Branch 586 not taken.
✗ Branch 587 not taken.
✗ Branch 588 not taken.
✗ Branch 589 not taken.
✗ Branch 590 not taken.
✗ Branch 591 not taken.
✗ Branch 592 not taken.
✗ Branch 593 not taken.
✗ Branch 594 not taken.
✗ Branch 595 not taken.
✗ Branch 596 not taken.
✗ Branch 597 not taken.
✗ Branch 598 not taken.
✗ Branch 599 not taken.
✗ Branch 600 not taken.
✗ Branch 601 not taken.
✗ Branch 602 not taken.
✗ Branch 603 not taken.
✗ Branch 604 not taken.
✓ Branch 605 taken 53 times.
✗ Branch 606 not taken.
✗ Branch 607 not taken.
✗ Branch 608 not taken.
✗ Branch 609 not taken.
✗ Branch 610 not taken.
✓ Branch 611 taken 1751295 times.
✓ Branch 612 taken 14532 times.
✗ Branch 613 not taken.
✗ Branch 614 not taken.
✗ Branch 615 not taken.
✗ Branch 616 not taken.
✗ Branch 617 not taken.
✗ Branch 618 not taken.
✗ Branch 619 not taken.
✗ Branch 620 not taken.
✓ Branch 621 taken 140 times.
✓ Branch 622 taken 1765 times.
✗ Branch 623 not taken.
✗ Branch 624 not taken.
✗ Branch 625 not taken.
✗ Branch 626 not taken.
✗ Branch 627 not taken.
✗ Branch 628 not taken.
✗ Branch 629 not taken.
✗ Branch 630 not taken.
✗ Branch 631 not taken.
✗ Branch 632 not taken.
✗ Branch 633 not taken.
✗ Branch 634 not taken.
✗ Branch 635 not taken.
✓ Branch 636 taken 55501 times.
✗ Branch 637 not taken.
✓ Branch 638 taken 55501 times.
✓ Branch 639 taken 63041 times.
✓ Branch 640 taken 142873 times.
✓ Branch 641 taken 74538 times.
✗ Branch 642 not taken.
✗ Branch 643 not taken.
✗ Branch 644 not taken.
✗ Branch 645 not taken.
✗ Branch 646 not taken.
✓ Branch 647 taken 77691 times.
✗ Branch 648 not taken.
✗ Branch 649 not taken.
✗ Branch 650 not taken.
✗ Branch 651 not taken.
✗ Branch 652 not taken.
✗ Branch 653 not taken.
✓ Branch 654 taken 426414 times.
✓ Branch 655 taken 436097 times.
✗ Branch 656 not taken.
✓ Branch 657 taken 410674 times.
✗ Branch 658 not taken.
✗ Branch 659 not taken.
✓ Branch 660 taken 5126984 times.
✗ Branch 661 not taken.
✓ Branch 662 taken 165740 times.
✗ Branch 663 not taken.
✓ Branch 664 taken 1130026 times.
✓ Branch 665 taken 472577 times.
✗ Branch 666 not taken.
✓ Branch 667 taken 532410 times.
✓ Branch 668 taken 3169 times.
✓ Branch 669 taken 13200 times.
✓ Branch 670 taken 5408 times.
✓ Branch 671 taken 39139 times.
✗ Branch 672 not taken.
✗ Branch 673 not taken.
✓ Branch 674 taken 404 times.
✗ Branch 675 not taken.
✓ Branch 676 taken 17988 times.
✗ Branch 677 not taken.
✗ Branch 678 not taken.
✓ Branch 679 taken 6086 times.
✓ Branch 680 taken 383015 times.
✓ Branch 681 taken 383015 times.
✓ Branch 682 taken 427914 times.
✓ Branch 683 taken 427914 times.
✓ Branch 684 taken 226198 times.
✗ Branch 685 not taken.
✓ Branch 686 taken 1505295 times.
✓ Branch 687 taken 1487420 times.
✓ Branch 688 taken 1058433 times.
✗ Branch 689 not taken.
✓ Branch 690 taken 1035974 times.
✓ Branch 691 taken 603415 times.
✓ Branch 692 taken 2064045 times.
✓ Branch 693 taken 2065021 times.
✗ Branch 694 not taken.
✗ Branch 695 not taken.
✗ Branch 696 not taken.
✓ Branch 697 taken 2064017 times.
✓ Branch 698 taken 75623 times.
✗ Branch 699 not taken.
✗ Branch 700 not taken.
✗ Branch 701 not taken.
✗ Branch 702 not taken.
✗ Branch 703 not taken.
✗ Branch 704 not taken.
✓ Branch 705 taken 527244 times.
✗ Branch 706 not taken.
✓ Branch 707 taken 22519029 times.
✗ Branch 708 not taken.
✓ Branch 709 taken 598 times.
✗ Branch 710 not taken.
✓ Branch 711 taken 3672930 times.
✓ Branch 712 taken 167669 times.
✓ Branch 713 taken 268246 times.
✗ Branch 714 not taken.
✓ Branch 715 taken 11384507 times.
✗ Branch 716 not taken.
✗ Branch 717 not taken.
✓ Branch 718 taken 6431345 times.
✗ Branch 719 not taken.
✗ Branch 720 not taken.
✗ Branch 721 not taken.
✗ Branch 722 not taken.
✗ Branch 723 not taken.
✗ Branch 724 not taken.
✗ Branch 725 not taken.
✗ Branch 726 not taken.
✗ Branch 727 not taken.
✗ Branch 728 not taken.
✗ Branch 729 not taken.
✗ Branch 730 not taken.
✗ Branch 731 not taken.
✗ Branch 732 not taken.
✗ Branch 733 not taken.
✗ Branch 734 not taken.
✗ Branch 735 not taken.
✗ Branch 736 not taken.
✗ Branch 737 not taken.
✗ Branch 738 not taken.
✗ Branch 739 not taken.
✗ Branch 740 not taken.
✗ Branch 741 not taken.
✗ Branch 742 not taken.
✗ Branch 743 not taken.
✓ Branch 744 taken 85830 times.
✓ Branch 745 taken 1122 times.
✓ Branch 746 taken 3785245 times.
✓ Branch 747 taken 49772 times.
✗ Branch 748 not taken.
✗ Branch 749 not taken.
✓ Branch 750 taken 3289 times.
✗ Branch 751 not taken.
✓ Branch 752 taken 830567 times.
✓ Branch 753 taken 132394 times.
✗ Branch 754 not taken.
✗ Branch 755 not taken.
✗ Branch 756 not taken.
✓ Branch 757 taken 133136 times.
✓ Branch 758 taken 25249 times.
✗ Branch 759 not taken.
✗ Branch 760 not taken.
✓ Branch 761 taken 179 times.
✗ Branch 762 not taken.
✗ Branch 763 not taken.
✗ Branch 764 not taken.
✗ Branch 765 not taken.
✗ Branch 766 not taken.
✓ Branch 767 taken 22679 times.
✗ Branch 768 not taken.
✗ Branch 769 not taken.
✗ Branch 770 not taken.
✗ Branch 771 not taken.
✓ Branch 772 taken 46359 times.
✓ Branch 773 taken 154 times.
✗ Branch 774 not taken.
✓ Branch 775 taken 70 times.
✓ Branch 776 taken 70 times.
✗ Branch 777 not taken.
✓ Branch 778 taken 218 times.
✓ Branch 779 taken 1913436 times.
✗ Branch 780 not taken.
✓ Branch 781 taken 2925 times.
✗ Branch 782 not taken.
✓ Branch 783 taken 65540 times.
✓ Branch 784 taken 62523 times.
✓ Branch 785 taken 13780500 times.
✗ Branch 786 not taken.
✗ Branch 787 not taken.
✗ Branch 788 not taken.
✗ Branch 789 not taken.
✗ Branch 790 not taken.
✗ Branch 791 not taken.
✗ Branch 792 not taken.
✗ Branch 793 not taken.
✗ Branch 794 not taken.
✗ Branch 795 not taken.
✗ Branch 796 not taken.
✓ Branch 797 taken 2103 times.
✗ Branch 798 not taken.
✗ Branch 799 not taken.
✓ Branch 800 taken 17 times.
✓ Branch 801 taken 678 times.
✓ Branch 802 taken 14 times.
✓ Branch 803 taken 4033084 times.
✗ Branch 804 not taken.
✗ Branch 805 not taken.
✓ Branch 806 taken 700 times.
✗ Branch 807 not taken.
✗ Branch 808 not taken.
✗ Branch 809 not taken.
✗ Branch 810 not taken.
✗ Branch 811 not taken.
✗ Branch 812 not taken.
✗ Branch 813 not taken.
✗ Branch 814 not taken.
✗ Branch 815 not taken.
✗ Branch 816 not taken.
✗ Branch 817 not taken.
✗ Branch 818 not taken.
✓ Branch 819 taken 191517 times.
✓ Branch 820 taken 1218351 times.
✗ Branch 821 not taken.
✗ Branch 822 not taken.
✗ Branch 823 not taken.
✗ Branch 824 not taken.
✗ Branch 825 not taken.
✓ Branch 826 taken 18739404 times.
✗ Branch 827 not taken.
✓ Branch 828 taken 14112446 times.
✓ Branch 829 taken 5922840 times.
✓ Branch 830 taken 14025143 times.
✗ Branch 831 not taken.
✗ Branch 832 not taken.
✗ Branch 833 not taken.
✗ Branch 834 not taken.
✗ Branch 835 not taken.
✗ Branch 836 not taken.
✗ Branch 837 not taken.
✗ Branch 838 not taken.
✗ Branch 839 not taken.
✗ Branch 840 not taken.
✗ Branch 841 not taken.
✓ Branch 842 taken 1764243 times.
✓ Branch 843 taken 1019 times.
✓ Branch 844 taken 255560 times.
✗ Branch 845 not taken.
✓ Branch 846 taken 741668 times.
✓ Branch 847 taken 96115 times.
✓ Branch 848 taken 9482 times.
✓ Branch 849 taken 37 times.
✓ Branch 850 taken 27341446 times.
✓ Branch 851 taken 2709583 times.
✓ Branch 852 taken 3906326 times.
✓ Branch 853 taken 26494416 times.
✓ Branch 854 taken 2975118 times.
✓ Branch 855 taken 96784 times.
✗ Branch 856 not taken.
✓ Branch 857 taken 13758809 times.
✓ Branch 858 taken 2272124 times.
✓ Branch 859 taken 5866709 times.
✓ Branch 860 taken 449777 times.
✓ Branch 861 taken 421915 times.
✓ Branch 862 taken 6342577 times.
✗ Branch 863 not taken.
✗ Branch 864 not taken.
✗ Branch 865 not taken.
✗ Branch 866 not taken.
✗ Branch 867 not taken.
✗ Branch 868 not taken.
✗ Branch 869 not taken.
✗ Branch 870 not taken.
✗ Branch 871 not taken.
✗ Branch 872 not taken.
✗ Branch 873 not taken.
✗ Branch 874 not taken.
✗ Branch 875 not taken.
✗ Branch 876 not taken.
✗ Branch 877 not taken.
✗ Branch 878 not taken.
✗ Branch 879 not taken.
✗ Branch 880 not taken.
✗ Branch 881 not taken.
✗ Branch 882 not taken.
✓ Branch 883 taken 54 times.
✗ Branch 884 not taken.
✗ Branch 885 not taken.
✗ Branch 886 not taken.
✗ Branch 887 not taken.
✗ Branch 888 not taken.
✗ Branch 889 not taken.
✗ Branch 890 not taken.
✓ Branch 891 taken 109824 times.
✗ Branch 892 not taken.
✗ Branch 893 not taken.
✗ Branch 894 not taken.
✗ Branch 895 not taken.
✗ Branch 896 not taken.
✗ Branch 897 not taken.
✗ Branch 898 not taken.
✗ Branch 899 not taken.
✗ Branch 900 not taken.
✗ Branch 901 not taken.
✗ Branch 902 not taken.
✗ Branch 903 not taken.
✗ Branch 904 not taken.
✗ Branch 905 not taken.
✓ Branch 906 taken 390022 times.
✓ Branch 907 taken 4 times.
✗ Branch 908 not taken.
✗ Branch 909 not taken.
✗ Branch 910 not taken.
✗ Branch 911 not taken.
✗ Branch 912 not taken.
✗ Branch 913 not taken.
✗ Branch 914 not taken.
✗ Branch 915 not taken.
✓ Branch 916 taken 229939 times.
✓ Branch 917 taken 91 times.
✗ Branch 918 not taken.
✗ Branch 919 not taken.
✓ Branch 920 taken 1 times.
✗ Branch 921 not taken.
✗ Branch 922 not taken.
✗ Branch 923 not taken.
✗ Branch 924 not taken.
✗ Branch 925 not taken.
✓ Branch 926 taken 16 times.
✗ Branch 927 not taken.
✓ Branch 928 taken 16 times.
✗ Branch 929 not taken.
✓ Branch 930 taken 16 times.
✓ Branch 931 taken 16 times.
✗ Branch 932 not taken.
✗ Branch 933 not taken.
✗ Branch 934 not taken.
✗ Branch 935 not taken.
✓ Branch 936 taken 3670 times.
✓ Branch 937 taken 192 times.
✗ Branch 938 not taken.
✗ Branch 939 not taken.
✗ Branch 940 not taken.
✗ Branch 941 not taken.
✗ Branch 942 not taken.
✗ Branch 943 not taken.
✗ Branch 944 not taken.
✗ Branch 945 not taken.
✗ Branch 946 not taken.
✗ Branch 947 not taken.
✗ Branch 948 not taken.
✗ Branch 949 not taken.
✗ Branch 950 not taken.
✗ Branch 951 not taken.
✓ Branch 952 taken 192 times.
✗ Branch 953 not taken.
✗ Branch 954 not taken.
✗ Branch 955 not taken.
✗ Branch 956 not taken.
✗ Branch 957 not taken.
✗ Branch 958 not taken.
✗ Branch 959 not taken.
✗ Branch 960 not taken.
✗ Branch 961 not taken.
✗ Branch 962 not taken.
✗ Branch 963 not taken.
✗ Branch 964 not taken.
✗ Branch 965 not taken.
✗ Branch 966 not taken.
✗ Branch 967 not taken.
✗ Branch 968 not taken.
✗ Branch 969 not taken.
✗ Branch 970 not taken.
✗ Branch 971 not taken.
✗ Branch 972 not taken.
✗ Branch 973 not taken.
✓ Branch 974 taken 13 times.
✓ Branch 975 taken 13 times.
✗ Branch 976 not taken.
✗ Branch 977 not taken.
✗ Branch 978 not taken.
✗ Branch 979 not taken.
✓ Branch 980 taken 128 times.
✓ Branch 981 taken 128 times.
✓ Branch 982 taken 128 times.
✗ Branch 983 not taken.
✗ Branch 984 not taken.
✗ Branch 985 not taken.
✓ Branch 986 taken 200 times.
✓ Branch 987 taken 8 times.
✓ Branch 988 taken 5 times.
✓ Branch 989 taken 392 times.
✓ Branch 990 taken 392 times.
✓ Branch 991 taken 5 times.
✓ Branch 992 taken 5 times.
✓ Branch 993 taken 5 times.
✓ Branch 994 taken 5 times.
✓ Branch 995 taken 91 times.
✗ Branch 996 not taken.
✓ Branch 997 taken 32 times.
✗ Branch 998 not taken.
✗ Branch 999 not taken.
✗ Branch 1000 not taken.
✗ Branch 1001 not taken.
✓ Branch 1002 taken 8 times.
✓ Branch 1003 taken 8 times.
✓ Branch 1004 taken 5 times.
✓ Branch 1005 taken 5 times.
✗ Branch 1006 not taken.
✓ Branch 1007 taken 32773 times.
✓ Branch 1008 taken 1800 times.
✗ Branch 1009 not taken.
✗ Branch 1010 not taken.
✗ Branch 1011 not taken.
✗ Branch 1012 not taken.
✗ Branch 1013 not taken.
✗ Branch 1014 not taken.
✗ Branch 1015 not taken.
✗ Branch 1016 not taken.
✗ Branch 1017 not taken.
✗ Branch 1018 not taken.
✗ Branch 1019 not taken.
✓ Branch 1020 taken 18 times.
✓ Branch 1021 taken 42 times.
✓ Branch 1022 taken 6 times.
✗ Branch 1023 not taken.
✓ Branch 1024 taken 4767952 times.
✓ Branch 1025 taken 4654485 times.
✓ Branch 1026 taken 5945377 times.
✓ Branch 1027 taken 2540907 times.
✓ Branch 1028 taken 345816 times.
✓ Branch 1029 taken 85947 times.
✗ Branch 1030 not taken.
✓ Branch 1031 taken 45056 times.
✗ Branch 1032 not taken.
✗ Branch 1033 not taken.
✗ Branch 1034 not taken.
✗ Branch 1035 not taken.
✗ Branch 1036 not taken.
✗ Branch 1037 not taken.
✗ Branch 1038 not taken.
✗ Branch 1039 not taken.
✗ Branch 1040 not taken.
✗ Branch 1041 not taken.
✗ Branch 1042 not taken.
✗ Branch 1043 not taken.
✓ Branch 1044 taken 701 times.
✗ Branch 1045 not taken.
✓ Branch 1046 taken 6 times.
✓ Branch 1047 taken 192 times.
✗ Branch 1048 not taken.
✓ Branch 1049 taken 43092 times.
✓ Branch 1050 taken 45 times.
✓ Branch 1051 taken 1402 times.
✓ Branch 1052 taken 17 times.
✗ Branch 1053 not taken.
✗ Branch 1054 not taken.
✗ Branch 1055 not taken.
✓ Branch 1056 taken 6 times.
✗ Branch 1057 not taken.
✗ Branch 1058 not taken.
✗ Branch 1059 not taken.
✗ Branch 1060 not taken.
✗ Branch 1061 not taken.
✗ Branch 1062 not taken.
✗ Branch 1063 not taken.
✗ Branch 1064 not taken.
✗ Branch 1065 not taken.
✗ Branch 1066 not taken.
✗ Branch 1067 not taken.
✗ Branch 1068 not taken.
✗ Branch 1069 not taken.
✗ Branch 1070 not taken.
✗ Branch 1071 not taken.
✗ Branch 1072 not taken.
✗ Branch 1073 not taken.
✗ Branch 1074 not taken.
✗ Branch 1075 not taken.
✗ Branch 1076 not taken.
✗ Branch 1077 not taken.
✗ Branch 1078 not taken.
✗ Branch 1079 not taken.
✗ Branch 1080 not taken.
✗ Branch 1081 not taken.
✗ Branch 1082 not taken.
✗ Branch 1083 not taken.
✗ Branch 1084 not taken.
✗ Branch 1085 not taken.
✓ Branch 1086 taken 11261 times.
✓ Branch 1087 taken 11261 times.
✓ Branch 1088 taken 33759 times.
✓ Branch 1089 taken 11044 times.
✓ Branch 1090 taken 4546 times.
✗ Branch 1091 not taken.
✗ Branch 1092 not taken.
✗ Branch 1093 not taken.
✗ Branch 1094 not taken.
✓ Branch 1095 taken 4546 times.
✗ Branch 1096 not taken.
✗ Branch 1097 not taken.
✓ Branch 1098 taken 4890 times.
✗ Branch 1099 not taken.
✗ Branch 1100 not taken.
✓ Branch 1101 taken 22172 times.
✗ Branch 1102 not taken.
✗ Branch 1103 not taken.
✗ Branch 1104 not taken.
✗ Branch 1105 not taken.
✗ Branch 1106 not taken.
✗ Branch 1107 not taken.
✗ Branch 1108 not taken.
✗ Branch 1109 not taken.
✗ Branch 1110 not taken.
✓ Branch 1111 taken 66 times.
✓ Branch 1112 taken 1636 times.
✓ Branch 1113 taken 568 times.
✓ Branch 1114 taken 136 times.
✗ Branch 1115 not taken.
✗ Branch 1116 not taken.
✗ Branch 1117 not taken.
✗ Branch 1118 not taken.
✗ Branch 1119 not taken.
✗ Branch 1120 not taken.
✗ Branch 1121 not taken.
✗ Branch 1122 not taken.
✗ Branch 1123 not taken.
✗ Branch 1124 not taken.
✗ Branch 1125 not taken.
✗ Branch 1126 not taken.
✗ Branch 1127 not taken.
✗ Branch 1128 not taken.
✗ Branch 1129 not taken.
✗ Branch 1130 not taken.
✗ Branch 1131 not taken.
✗ Branch 1132 not taken.
✗ Branch 1133 not taken.
✗ Branch 1134 not taken.
✗ Branch 1135 not taken.
✗ Branch 1136 not taken.
✗ Branch 1137 not taken.
✗ Branch 1138 not taken.
✗ Branch 1139 not taken.
✗ Branch 1140 not taken.
✗ Branch 1141 not taken.
✗ Branch 1142 not taken.
✗ Branch 1143 not taken.
✗ Branch 1144 not taken.
✗ Branch 1145 not taken.
✗ Branch 1146 not taken.
✗ Branch 1147 not taken.
✗ Branch 1148 not taken.
✗ Branch 1149 not taken.
✗ Branch 1150 not taken.
✗ Branch 1151 not taken.
✗ Branch 1152 not taken.
✗ Branch 1153 not taken.
✗ Branch 1154 not taken.
✗ Branch 1155 not taken.
✗ Branch 1156 not taken.
✗ Branch 1157 not taken.
✗ Branch 1158 not taken.
✓ Branch 1159 taken 10673 times.
✗ Branch 1160 not taken.
✗ Branch 1161 not taken.
✗ Branch 1162 not taken.
✗ Branch 1163 not taken.
✗ Branch 1164 not taken.
✗ Branch 1165 not taken.
✗ Branch 1166 not taken.
✗ Branch 1167 not taken.
✗ Branch 1168 not taken.
✗ Branch 1169 not taken.
✗ Branch 1170 not taken.
✗ Branch 1171 not taken.
✗ Branch 1172 not taken.
✗ Branch 1173 not taken.
✗ Branch 1174 not taken.
✗ Branch 1175 not taken.
✗ Branch 1176 not taken.
✗ Branch 1177 not taken.
✗ Branch 1178 not taken.
✗ Branch 1179 not taken.
✗ Branch 1180 not taken.
✗ Branch 1181 not taken.
✗ Branch 1182 not taken.
✗ Branch 1183 not taken.
✗ Branch 1184 not taken.
✗ Branch 1185 not taken.
✗ Branch 1186 not taken.
✗ Branch 1187 not taken.
✗ Branch 1188 not taken.
✗ Branch 1189 not taken.
✗ Branch 1190 not taken.
✗ Branch 1191 not taken.
✗ Branch 1192 not taken.
✗ Branch 1193 not taken.
✗ Branch 1194 not taken.
✗ Branch 1195 not taken.
✗ Branch 1196 not taken.
✗ Branch 1197 not taken.
✗ Branch 1198 not taken.
✗ Branch 1199 not taken.
✗ Branch 1200 not taken.
✗ Branch 1201 not taken.
✗ Branch 1202 not taken.
✗ Branch 1203 not taken.
✗ Branch 1204 not taken.
✗ Branch 1205 not taken.
✗ Branch 1206 not taken.
✗ Branch 1207 not taken.
✗ Branch 1208 not taken.
✗ Branch 1209 not taken.
✗ Branch 1210 not taken.
✗ Branch 1211 not taken.
✗ Branch 1212 not taken.
✗ Branch 1213 not taken.
✗ Branch 1214 not taken.
✗ Branch 1215 not taken.
✗ Branch 1216 not taken.
✗ Branch 1217 not taken.
✗ Branch 1218 not taken.
✗ Branch 1219 not taken.
✗ Branch 1220 not taken.
✗ Branch 1221 not taken.
✗ Branch 1222 not taken.
✗ Branch 1223 not taken.
✗ Branch 1224 not taken.
✗ Branch 1225 not taken.
✗ Branch 1226 not taken.
✗ Branch 1227 not taken.
✗ Branch 1228 not taken.
✗ Branch 1229 not taken.
✗ Branch 1230 not taken.
✗ Branch 1231 not taken.
✗ Branch 1232 not taken.
✗ Branch 1233 not taken.
✗ Branch 1234 not taken.
✗ Branch 1235 not taken.
✗ Branch 1236 not taken.
✗ Branch 1237 not taken.
✗ Branch 1238 not taken.
✗ Branch 1239 not taken.
✗ Branch 1240 not taken.
✗ Branch 1241 not taken.
✗ Branch 1242 not taken.
✗ Branch 1243 not taken.
✗ Branch 1244 not taken.
✗ Branch 1245 not taken.
✗ Branch 1246 not taken.
✗ Branch 1247 not taken.
✗ Branch 1248 not taken.
✗ Branch 1249 not taken.
✗ Branch 1250 not taken.
✗ Branch 1251 not taken.
✗ Branch 1252 not taken.
✗ Branch 1253 not taken.
✗ Branch 1254 not taken.
✗ Branch 1255 not taken.
✗ Branch 1256 not taken.
✗ Branch 1257 not taken.
✗ Branch 1258 not taken.
✗ Branch 1259 not taken.
✗ Branch 1260 not taken.
✗ Branch 1261 not taken.
✗ Branch 1262 not taken.
✗ Branch 1263 not taken.
✗ Branch 1264 not taken.
✗ Branch 1265 not taken.
✗ Branch 1266 not taken.
✗ Branch 1267 not taken.
✗ Branch 1268 not taken.
✗ Branch 1269 not taken.
✗ Branch 1270 not taken.
✗ Branch 1271 not taken.
✗ Branch 1272 not taken.
✗ Branch 1273 not taken.
✗ Branch 1274 not taken.
✗ Branch 1275 not taken.
✗ Branch 1276 not taken.
✗ Branch 1277 not taken.
✗ Branch 1278 not taken.
✗ Branch 1279 not taken.
✗ Branch 1280 not taken.
✗ Branch 1281 not taken.
✗ Branch 1282 not taken.
✗ Branch 1283 not taken.
✗ Branch 1284 not taken.
✗ Branch 1285 not taken.
✗ Branch 1286 not taken.
✗ Branch 1287 not taken.
✗ Branch 1288 not taken.
✗ Branch 1289 not taken.
✗ Branch 1290 not taken.
✗ Branch 1291 not taken.
✓ Branch 1292 taken 1817944 times.
✓ Branch 1293 taken 1340238 times.
✓ Branch 1294 taken 25786 times.
✓ Branch 1295 taken 16 times.
✗ Branch 1296 not taken.
✗ Branch 1297 not taken.
✗ Branch 1298 not taken.
✗ Branch 1299 not taken.
✗ Branch 1300 not taken.
✗ Branch 1301 not taken.
✗ Branch 1302 not taken.
✗ Branch 1303 not taken.
✗ Branch 1304 not taken.
✗ Branch 1305 not taken.
✗ Branch 1306 not taken.
✗ Branch 1307 not taken.
✗ Branch 1308 not taken.
✗ Branch 1309 not taken.
✗ Branch 1310 not taken.
✗ Branch 1311 not taken.
✗ Branch 1312 not taken.
✗ Branch 1313 not taken.
✗ Branch 1314 not taken.
✗ Branch 1315 not taken.
✗ Branch 1316 not taken.
✗ Branch 1317 not taken.
✗ Branch 1318 not taken.
✗ Branch 1319 not taken.
✗ Branch 1320 not taken.
✗ Branch 1321 not taken.
✗ Branch 1322 not taken.
✗ Branch 1323 not taken.
✗ Branch 1324 not taken.
✗ Branch 1325 not taken.
✗ Branch 1326 not taken.
✗ Branch 1327 not taken.
✗ Branch 1328 not taken.
✗ Branch 1329 not taken.
✗ Branch 1330 not taken.
✗ Branch 1331 not taken.
✗ Branch 1332 not taken.
✗ Branch 1333 not taken.
✗ Branch 1334 not taken.
✗ Branch 1335 not taken.
✗ Branch 1336 not taken.
✗ Branch 1337 not taken.
✗ Branch 1338 not taken.
✗ Branch 1339 not taken.
✗ Branch 1340 not taken.
✗ Branch 1341 not taken.
✗ Branch 1342 not taken.
✗ Branch 1343 not taken.
✗ Branch 1344 not taken.
✗ Branch 1345 not taken.
✗ Branch 1346 not taken.
✗ Branch 1347 not taken.
✗ Branch 1348 not taken.
✗ Branch 1349 not taken.
✗ Branch 1350 not taken.
✗ Branch 1351 not taken.
✗ Branch 1352 not taken.
✗ Branch 1353 not taken.
✗ Branch 1354 not taken.
✗ Branch 1355 not taken.
✗ Branch 1356 not taken.
✗ Branch 1357 not taken.
✗ Branch 1358 not taken.
✗ Branch 1359 not taken.
✗ Branch 1360 not taken.
✗ Branch 1361 not taken.
✗ Branch 1362 not taken.
✗ Branch 1363 not taken.
✗ Branch 1364 not taken.
✗ Branch 1365 not taken.
✗ Branch 1366 not taken.
✗ Branch 1367 not taken.
✗ Branch 1368 not taken.
✗ Branch 1369 not taken.
✗ Branch 1370 not taken.
✗ Branch 1371 not taken.
✗ Branch 1372 not taken.
✗ Branch 1373 not taken.
✗ Branch 1374 not taken.
✗ Branch 1375 not taken.
✗ Branch 1376 not taken.
✗ Branch 1377 not taken.
✗ Branch 1378 not taken.
✗ Branch 1379 not taken.
✗ Branch 1380 not taken.
✗ Branch 1381 not taken.
✗ Branch 1382 not taken.
✗ Branch 1383 not taken.
✗ Branch 1384 not taken.
✗ Branch 1385 not taken.
✗ Branch 1386 not taken.
✗ Branch 1387 not taken.
✗ Branch 1388 not taken.
✗ Branch 1389 not taken.
✗ Branch 1390 not taken.
✗ Branch 1391 not taken.
✗ Branch 1392 not taken.
✗ Branch 1393 not taken.
✗ Branch 1394 not taken.
✗ Branch 1395 not taken.
✗ Branch 1396 not taken.
✗ Branch 1397 not taken.
✗ Branch 1398 not taken.
✗ Branch 1399 not taken.
✗ Branch 1400 not taken.
✗ Branch 1401 not taken.
✗ Branch 1402 not taken.
✗ Branch 1403 not taken.
✗ Branch 1404 not taken.
✗ Branch 1405 not taken.
✗ Branch 1406 not taken.
✗ Branch 1407 not taken.
2767297062 switch(arg)
3767 {
3768
3769 case INCQST:
3770 {
3771 //zprint2("Incrementing Quest\n");
3772 int32_t newqst = 0;
3773 if ( game->get_quest() < 255 ) //255 is a custom quest
3774 {
3775 newqst = (game->get_quest()+1);
3776 }
3777 else
3778 {
3779 newqst = 1;
3780 }
3781 //zprint2("newqst is: %d\n", newqst);
3782 if ( newqst < 11 )
3783 {
3784
3785 ret = newqst * 10000;
3786 Quit = qINCQST;
3787 //ending();
3788
3789 }
3790 else ret = -10000;
3791 break;
3792 }
3793 //Debug->Null()
3794 case DONULL:
3795 ret = 0;
3796 break;
3797 case DEBUGTESTING:
3798 43 ret = use_testingst_start ? 10000 : 0;
3799 43 break;
3800
3801 //debug ri->d[]
3802 case DEBUGD:
3803 {
3804 int32_t a = ri->d[rINDEX] / 10000;
3805 ret = ri->d[a] * 10000;
3806 break;
3807 }
3808
3809 ///----------------------------------------------------------------------------------------------------//
3810 //FFC Variables
3811 case DATA:
3812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440400 times.
4440400 if(BC::checkFFC(ri->ffcref, "ffc->Data") == SH::_NoError)
3813 4440400 ret = tmpscr->ffcs[ri->ffcref].getData() *10000;
3814 4440400 break;
3815
3816 case FFSCRIPT:
3817
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 468470857 times.
468471069 if(BC::checkFFC(ri->ffcref, "ffc->Script") == SH::_NoError)
3818 468470857 ret = tmpscr->ffcs[ri->ffcref].script*10000;
3819 468471069 break;
3820
3821 case FCSET:
3822
1/2
✓ Branch 0 taken 1184834 times.
✗ Branch 1 not taken.
1184834 if(BC::checkFFC(ri->ffcref, "ffc->CSet") == SH::_NoError)
3823 1184834 ret = tmpscr->ffcs[ri->ffcref].cset*10000;
3824 1184834 break;
3825
3826 case DELAY:
3827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(BC::checkFFC(ri->ffcref, "ffc->Delay") == SH::_NoError)
3828 5 ret = tmpscr->ffcs[ri->ffcref].delay*10000;
3829 5 break;
3830
3831 case FX:
3832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8343964 times.
8343964 if(BC::checkFFC(ri->ffcref, "ffc->X") == SH::_NoError)
3833 8343964 ret = tmpscr->ffcs[ri->ffcref].x.getZLong();
3834 8343964 break;
3835
3836 case FY:
3837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7892558 times.
7892558 if(BC::checkFFC(ri->ffcref, "ffc->Y") == SH::_NoError)
3838 7892558 ret = tmpscr->ffcs[ri->ffcref].y.getZLong();
3839 7892558 break;
3840
3841 case XD:
3842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(BC::checkFFC(ri->ffcref, "ffc->Vx") == SH::_NoError)
3843 35 ret = tmpscr->ffcs[ri->ffcref].vx.getZLong();
3844 35 break;
3845
3846 case YD:
3847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(BC::checkFFC(ri->ffcref, "ffc->Vy") == SH::_NoError)
3848 35 ret = tmpscr->ffcs[ri->ffcref].vy.getZLong();
3849 35 break;
3850 case FFCID:
3851 if(BC::checkFFC(ri->ffcref, "ffc->ID") == SH::_NoError)
3852 ret=(ri->ffcref*10000)+10000;
3853 break;
3854
3855 case XD2:
3856
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(BC::checkFFC(ri->ffcref, "ffc->Ax") == SH::_NoError)
3857 35 ret = tmpscr->ffcs[ri->ffcref].ax.getZLong();
3858 35 break;
3859
3860 case YD2:
3861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(BC::checkFFC(ri->ffcref, "ffc->Ay") == SH::_NoError)
3862 35 ret = tmpscr->ffcs[ri->ffcref].ay.getZLong();
3863 35 break;
3864
3865 case FFFLAGSD:
3866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2180472 times.
2180472 if(BC::checkFFC(ri->ffcref, "ffc->Flags[]") == SH::_NoError)
3867 2180472 ret=((tmpscr->ffcs[ri->ffcref].flags >> (ri->d[rINDEX] / 10000))&1) ? 10000 : 0;
3868 2180472 break;
3869
3870 case FFCWIDTH:
3871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if(BC::checkFFC(ri->ffcref, "ffc->EffectWidth") == SH::_NoError)
3872 103 ret=(tmpscr->ffcs[ri->ffcref].hit_width*10000);
3873 103 break;
3874
3875 case FFCHEIGHT:
3876
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if(BC::checkFFC(ri->ffcref, "ffc->EffectHeight") == SH::_NoError)
3877 98 ret=(tmpscr->ffcs[ri->ffcref].hit_height*10000);
3878 98 break;
3879
3880 case FFTWIDTH:
3881
1/2
✓ Branch 0 taken 2596310 times.
✗ Branch 1 not taken.
2596310 if(BC::checkFFC(ri->ffcref, "ffc->TileWidth") == SH::_NoError)
3882 2596310 ret=(tmpscr->ffcs[ri->ffcref].txsz*10000);
3883 2596310 break;
3884
3885 case FFTHEIGHT:
3886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2596581 times.
2596581 if(BC::checkFFC(ri->ffcref, "ffc->TileHeight") == SH::_NoError)
3887 2596581 ret=(tmpscr->ffcs[ri->ffcref].tysz*10000);
3888 2596581 break;
3889
3890 case FFLINK:
3891 if(BC::checkFFC(ri->ffcref, "ffc->Link") == SH::_NoError)
3892 ret=(tmpscr->ffcs[ri->ffcref].link)*10000;
3893 break;
3894
3895 case FFMISCD:
3896 {
3897 6076 int32_t a = ri->d[rINDEX] / 10000;
3898
3899
1/2
✓ Branch 0 taken 6076 times.
✗ Branch 1 not taken.
6076 if(BC::checkMisc(a, "ffc->Misc") != SH::_NoError)
3900 ret = -10000;
3901 else
3902 {
3903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6076 times.
6076 if(BC::checkFFC(ri->ffcref, "ffc->Misc[]") == SH::_NoError)
3904 6076 ret = ffmisc[ri->ffcref][a];
3905 }
3906 }
3907 6076 break;
3908
3909 case FFINITDD:
3910 {
3911 28819 int32_t a = ri->d[rINDEX] / 10000;
3912
3913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28819 times.
28819 if(BC::checkBounds(a, 0, 7, "ffc->InitD") != SH::_NoError)
3914 ret = -10000;
3915 else
3916 {
3917
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 28802 times.
28819 if(BC::checkFFC(ri->ffcref, "ffc->InitD[]") == SH::_NoError)
3918 28802 ret = tmpscr->ffcs[ri->ffcref].initd[a];
3919 }
3920 }
3921 28819 break;
3922
3923 ///----------------------------------------------------------------------------------------------------//
3924 //Hero's Variables
3925 case LINKX:
3926 {
3927
2/2
✓ Branch 0 taken 1457048 times.
✓ Branch 1 taken 13588557 times.
15045605 if (get_qr(qr_SPRITEXY_IS_FLOAT))
3928 {
3929 //double lx = (double)Hero.getX();
3930 //Z_scripterrlog("lx: %f\n", lx);
3931
3932 //ret = lx * 10000;
3933 //zfix lx = Hero.getX();
3934 //Z_scripterrlog("lx: %d\n", lx);
3935 1457048 ret = Hero.getX().getZLong();
3936 1457048 }
3937 13588557 else ret = int32_t(Hero.getX()) * 10000;
3938
3939 15045605 break;
3940 }
3941
3942 case LINKCSET:
3943 {
3944 1282 ret = Hero.cs * 10000;
3945 1282 break;
3946 }
3947 case LINKY:
3948 {
3949
2/2
✓ Branch 0 taken 1421794 times.
✓ Branch 1 taken 13481797 times.
14903591 if (get_qr(qr_SPRITEXY_IS_FLOAT))
3950 {
3951 1421794 ret = Hero.getY().getZLong();
3952 1421794 }
3953 13481797 else ret = int32_t(Hero.getY()) * 10000;
3954
3955 14903591 break;
3956 }
3957 case LINKZ:
3958 {
3959
2/2
✓ Branch 0 taken 95489 times.
✓ Branch 1 taken 468948 times.
564437 if (get_qr(qr_SPRITEXY_IS_FLOAT))
3960 {
3961 95489 ret = Hero.getZ().getZLong();
3962 95489 }
3963 468948 else ret = int32_t(Hero.getZ()) * 10000;
3964
3965 564437 break;
3966 }
3967 case LINKJUMP:
3968 // -fall/100*10000, but doing it that way screwed up the result
3969 641181 ret = Hero.getFall().getZLong() / -100;
3970 641181 break;
3971
3972 case HEROFAKEJUMP:
3973 ret = Hero.getFakeFall().getZLong() / -100;
3974 break;
3975
3976 case LINKDIR:
3977 765420 ret=(int32_t)(Hero.dir)*10000;
3978 765420 break;
3979
3980 case LINKHITDIR:
3981 ret=(int32_t)(Hero.getHitDir())*10000;
3982 break;
3983
3984 case LINKHP:
3985 15444780 ret=(int32_t)(game->get_life())*10000;
3986 15444780 break;
3987
3988 case LINKGRAVITY:
3989 ret = ( (Hero.moveflags & FLAG_OBEYS_GRAV) ? 10000 : 0 );
3990 break;
3991
3992 case HERONOSTEPFORWARD:
3993 ret = ( (FFCore.nostepforward) ? 10000 : 0 );
3994 break;
3995
3996 case LINKMP:
3997 2112268 ret=(int32_t)(game->get_magic())*10000;
3998 2112268 break;
3999
4000 case LINKMAXHP:
4001 655866 ret=(int32_t)(game->get_maxlife())*10000;
4002 655866 break;
4003
4004 case LINKMAXMP:
4005 552028 ret=(int32_t)(game->get_maxmagic())*10000;
4006 552028 break;
4007
4008 case LINKACTION:
4009 {
4010 //Z_scripterrlog("The present FFCore action is: %d\n", FFCore.getHeroAction());
4011 //int32_t act = FFCore.getHeroAction() * 10000;
4012 44802009 ret = FFCore.getHeroAction() * 10000;
4013 //Z_scripterrlog("The present 'action' return value is: %d\n", act);
4014 //ret = act;
4015 //ret=(int32_t)(Hero.getAction())*10000;
4016 44802009 break;
4017 }
4018
4019 case HEROHEALTHBEEP:
4020 {
4021 //Z_scripterrlog("The present FFCore action is: %d\n", FFCore.getHeroAction());
4022 //int32_t act = FFCore.getHeroAction() * 10000;
4023 ret = heart_beep ? ( heart_beep_timer * 10000 ) : 0;
4024 //Z_scripterrlog("The present 'action' return value is: %d\n", act);
4025 //ret = act;
4026 //ret=(int32_t)(Hero.getAction())*10000;
4027 break;
4028 }
4029
4030 case LINKHELD:
4031 17 ret = (int32_t)(Hero.getHeldItem())*10000;
4032 17 break;
4033
4034 case LINKITEMD:
4035 19615156 ret = game->item[vbound(ri->d[rINDEX]/10000, 0, MAXITEMS-1)] ? 10000 : 0;
4036 19615156 break;
4037
4038 case HEROSTEPS:
4039 ret = lsteps[vbound(ri->d[rINDEX]/10000, 0, 7)] * 10000;
4040 break;
4041
4042 case HEROSTEPRATE:
4043 5424 ret = Hero.getStepRate() * 10000;
4044 5424 break;
4045 case HEROSHOVEOFFSET:
4046 ret = Hero.shove_offset.getZLong();
4047 break;
4048
4049 case LINKEQUIP:
4050 801725 ret = ((Awpn&0xFF)|((Bwpn&0xFF)<<8))*10000;
4051 801725 break;
4052
4053 case LINKINVIS:
4054 557644 ret = (((int32_t)(Hero.getDontDraw())) ? 10000 : 0);
4055 557644 break;
4056
4057 case LINKINVINC:
4058 623338 ret = (int32_t)(Hero.scriptcoldet)*10000;
4059 623338 break;
4060
4061 case LINKENGINEANIMATE:
4062 ret = (int32_t)(Hero.do_animation)*10000;
4063 break;
4064
4065 case LINKLADDERX:
4066 ret=(int32_t)(Hero.getLadderX())*10000;
4067 break;
4068
4069 case LINKLADDERY:
4070 ret=(int32_t)(Hero.getLadderY())*10000;
4071 break;
4072
4073 case LINKSWORDJINX:
4074 280566 ret = (int32_t)(Hero.getSwordClk())*10000;
4075 280566 break;
4076
4077 case LINKITEMJINX:
4078 481556 ret = (int32_t)(Hero.getItemClk())*10000;
4079 481556 break;
4080
4081 case LINKDRUNK:
4082 ret = (int32_t)(Hero.DrunkClock())*10000;
4083 break;
4084
4085 case LINKMISCD:
4086 6213788 ret = (int32_t)(Hero.miscellaneous[vbound(ri->d[rINDEX]/10000,0,31)]); //Was this buffed before? -Z
4087 6213788 break;
4088
4089
4090 case LINKHITBY:
4091 {
4092 2929 int32_t indx = ri->d[rINDEX]/10000;
4093
1/3
✓ Branch 0 taken 2929 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2929 switch(indx)
4094 {
4095 //screen indices of objects
4096 case 0:
4097 case 1:
4098 case 2:
4099 case 3:
4100 case 8:
4101 case 9:
4102 case 10:
4103 case 11:
4104 case 12:
4105 case 16:
4106 {
4107 2929 ret = (int32_t)(Hero.gethitHeroUID(indx))* 10000;
4108 2929 break;
4109 }
4110 //uids of objects
4111 case 4:
4112 case 5:
4113 case 6:
4114 case 7:
4115 case 13:
4116 case 14:
4117 case 15:
4118 {
4119 ret = (int32_t)(Hero.gethitHeroUID(indx)); //do not multiply by 10000! UIDs are not *10000!
4120 break;
4121 }
4122 default: { Z_scripterrlog("Invalid index passed to Player->HitBy[%d]/n", indx); ret = -1; break; }
4123 }
4124 2929 break;
4125 }
4126 case LINKDEFENCE:
4127 ret = (int32_t)(Hero.get_defence(vbound(ri->d[rINDEX]/10000,0,255)))* 10000;
4128 break;
4129
4130
4131 case LINKROTATION:
4132 if ( get_qr(qr_OLDSPRITEDRAWS) )
4133 {
4134 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
4135 "Player->Rotation");
4136 ret = -1; break;
4137 }
4138 ret = (int32_t)(Hero.rotation)*10000;
4139 break;
4140
4141 case LINKSCALE:
4142 {
4143 if ( get_qr(qr_OLDSPRITEDRAWS) )
4144 {
4145 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
4146 "Player->Scale");
4147 ret = -1; break;
4148 }
4149 //al_trace("Player's scale is: %d\n", Hero.scale);
4150 ret = (int32_t)(Hero.scale*100.0);
4151 break;
4152 }
4153
4154
4155 case LINKHXOFS:
4156 206522 ret = (int32_t)(Hero.hxofs)*10000;
4157 206522 break;
4158
4159 case LINKHYOFS:
4160 206522 ret = (int32_t)(Hero.hyofs)*10000;
4161 206522 break;
4162
4163 case LINKXOFS:
4164 ret = (int32_t)(Hero.xofs)*10000;
4165 break;
4166
4167 case LINKYOFS:
4168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2402 times.
2402 ret = (int32_t)(Hero.yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset))*10000;
4169 2402 break;
4170
4171 case HEROSHADOWXOFS:
4172 ret = (int32_t)(Hero.shadowxofs)*10000;
4173 break;
4174
4175 case HEROSHADOWYOFS:
4176 ret = (int32_t)(Hero.shadowyofs)*10000;
4177 break;
4178
4179 case HEROTOTALDYOFFS:
4180 ret = 10000*(((int32_t)(Hero.yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)))
4181 + ((Hero.switch_hooked && Hero.switchhookstyle == swRISE)
4182 ? -(8-(abs(Hero.switchhookclk-32)/4)) : 0));
4183 break;
4184
4185 case LINKZOFS:
4186 ret = (int32_t)(Hero.zofs)*10000;
4187 break;
4188
4189 case LINKHXSZ:
4190 206547 ret = (int32_t)(Hero.hit_width)*10000;
4191 206547 break;
4192
4193 case LINKHYSZ:
4194 206547 ret = (int32_t)(Hero.hit_height)*10000;
4195 206547 break;
4196
4197 case LINKHZSZ:
4198 173466 ret = (int32_t)(Hero.hzsz)*10000;
4199 173466 break;
4200
4201 case LINKTXSZ:
4202 ret = (int32_t)(Hero.txsz)*10000;
4203 break;
4204
4205 case LINKTYSZ:
4206 ret = (int32_t)(Hero.tysz)*10000;
4207 break;
4208
4209 case LINKTILE:
4210 4636 ret = (int32_t)(Hero.tile)*10000;
4211 4636 break;
4212
4213 case LINKFLIP:
4214 ret = (int32_t)(Hero.flip)*10000;
4215 break;
4216
4217 case LINKINVFRAME:
4218 ret = (int32_t)Hero.getHClk()*10000;
4219 break;
4220
4221 case LINKCANFLICKER:
4222 ret= Hero.getCanFlicker()?10000:0;
4223 break;
4224 case LINKHURTSFX:
4225 ret = (int32_t)Hero.getHurtSFX()*10000;
4226 break;
4227
4228 /*
4229 case LINKUSINGITEM:
4230 ret = (int32_t)Hero.getDirectItem()*10000;
4231 break;
4232
4233 case LINKUSINGITEMA:
4234 ret = (int32_t)Hero.getDirectItemA()*10000;
4235 break;
4236
4237 case LINKUSINGITEMB:
4238 ret = (int32_t)Hero.getDirectItemB()*10000;
4239 break;
4240 */
4241
4242 case LINKEATEN:
4243 ret=(int32_t)Hero.getEaten()*10000;
4244 break;
4245 case LINKGRABBED:
4246 ret = Hero.inwallm ? 10000 : 0;
4247 break;
4248 case HEROBUNNY:
4249 ret = Hero.BunnyClock()*10000;
4250 break;
4251 case LINKPUSH:
4252 ret=(int32_t)Hero.getPushing()*10000;
4253 break;
4254 case LINKSTUN:
4255 ret=(int32_t)Hero.StunClock()*10000;
4256 break;
4257 case LINKSCRIPTTILE:
4258 2 ret=script_hero_sprite*10000;
4259 2 break;
4260
4261 case HEROSCRIPTCSET:
4262 ret=script_hero_cset*10000;
4263 break;
4264 case LINKSCRIPFLIP:
4265 ret=script_hero_flip*10000;
4266 break;
4267
4268
4269 case LINKITEMB:
4270 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
4271 19671 ret = Bwpn*10000;
4272 19671 break;
4273
4274 case LINKITEMA:
4275 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
4276 20320 ret = Awpn *10000;
4277 20320 break;
4278
4279 case LINKITEMX:
4280 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
4281 12319 ret = Xwpn *10000;
4282 12319 break;
4283
4284 case LINKITEMY:
4285 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
4286 13864 ret = Ywpn *10000;
4287 13864 break;
4288
4289 case LINKTILEMOD:
4290 ret = Hero.getTileModifier() * 10000;
4291 break;
4292
4293 case LINKDIAG:
4294 ret=Hero.getDiagMove()?10000:0;
4295 break;
4296
4297 case LINKBIGHITBOX:
4298 9024 ret=Hero.getBigHitbox()?10000:0;
4299 9024 break;
4300
4301 case LINKCLIMBING:
4302 ret = Hero.getOnSideviewLadder()?10000:0;
4303 break;
4304
4305 case HEROJUMPCOUNT:
4306 ret = Hero.extra_jump_count * 10000;
4307 break;
4308
4309 case HEROPULLDIR:
4310 ret = Hero.pit_pulldir * 10000;
4311 break;
4312
4313 case HEROPULLCLK:
4314 ret = Hero.pit_pullclk * 10000;
4315 break;
4316
4317 case HEROFALLCLK:
4318 88721 ret = Hero.fallclk * 10000;
4319 88721 break;
4320
4321 case HEROFALLCMB:
4322 ret = Hero.fallCombo * 10000;
4323 break;
4324
4325 case HERODROWNCLK:
4326 ret = Hero.drownclk * 10000;
4327 break;
4328
4329 case HERODROWNCMB:
4330 ret = Hero.drownCombo * 10000;
4331 break;
4332
4333 case HEROFAKEZ:
4334 {
4335 if (get_qr(qr_SPRITEXY_IS_FLOAT))
4336 {
4337 ret = Hero.getFakeZ().getZLong();
4338 }
4339 else ret = int32_t(Hero.getFakeZ()) * 10000;
4340
4341 break;
4342 }
4343 case HEROMOVEFLAGS:
4344 {
4345 int32_t indx = ri->d[rINDEX]/10000;
4346 if(BC::checkBounds(indx, 0, 10, "Hero->MoveFlags[]") != SH::_NoError)
4347 ret = 0; //false
4348 else
4349 {
4350 //All bits, in order, of a single byte; just use bitwise
4351 ret = (Hero.moveflags & (1<<indx)) ? 10000 : 0;
4352 }
4353 break;
4354 }
4355 case HEROLIFTFLAGS:
4356 {
4357 int32_t indx = ri->d[rINDEX]/10000;
4358 if(BC::checkBounds(indx, 0, NUM_LIFTFL-1, "Hero->LiftFlags[]") != SH::_NoError)
4359 ret = 0; //false
4360 else
4361 {
4362 ret = (Hero.liftflags & (1<<indx)) ? 10000 : 0;
4363 }
4364 break;
4365 }
4366
4367 case HEROSHIELDJINX:
4368 ret = Hero.shieldjinxclk * 10000;
4369 break;
4370
4371 case HEROISWARPING:
4372 561 ret = Hero.is_warping ? 10000L : 0L;
4373 561 break;
4374
4375 case CLOCKACTIVE:
4376 ret=watch?10000:0;
4377 break;
4378
4379 case CLOCKCLK:
4380 ret=clockclk*10000;
4381 break;
4382
4383 case HERORESPAWNX:
4384 {
4385 ret = Hero.respawn_x.getZLong();
4386 break;
4387 }
4388
4389 case HERORESPAWNY:
4390 {
4391 ret = Hero.respawn_y.getZLong();
4392 break;
4393 }
4394
4395 case HERORESPAWNDMAP:
4396 {
4397 ret = Hero.respawn_dmap * 10000;
4398 break;
4399 }
4400
4401 case HERORESPAWNSCR:
4402 {
4403 ret = Hero.respawn_scr * 10000;
4404 break;
4405 }
4406
4407 case HEROSWITCHTIMER:
4408 {
4409 ret = Hero.switchhookclk * 10000;
4410 break;
4411 }
4412
4413 case HEROSWITCHMAXTIMER:
4414 {
4415 ret = Hero.switchhookmaxtime * 10000;
4416 break;
4417 }
4418
4419 case HEROIMMORTAL:
4420 {
4421 ret = Hero.immortal * 10000;
4422 break;
4423 }
4424
4425 case HEROSTANDING:
4426 {
4427 ret = Hero.isStanding(true) ? 10000 : 0;
4428 break;
4429 }
4430
4431 case HEROCOYOTETIME:
4432 {
4433 ret = Hero.coyotetime*10000;
4434 break;
4435 }
4436
4437 case HEROLIFTEDWPN:
4438 {
4439 ret = Hero.lift_wpn ? Hero.lift_wpn->getUID() : 0;
4440 break;
4441 }
4442 case HEROLIFTTIMER:
4443 {
4444 ret = Hero.liftclk * 10000;
4445 break;
4446 }
4447 case HEROLIFTMAXTIMER:
4448 {
4449 ret = Hero.tliftclk * 10000;
4450 break;
4451 }
4452 case HEROLIFTHEIGHT:
4453 {
4454 ret = Hero.liftheight.getZLong();
4455 break;
4456 }
4457 case HEROHAMMERSTATE:
4458 {
4459 ret = Hero.getHammerState() * 10000;
4460 break;
4461 }
4462
4463 ///----------------------------------------------------------------------------------------------------//
4464 //Input States
4465 case INPUTSTART:
4466 92884 ret=control_state[6]?10000:0;
4467 92884 break;
4468
4469 case INPUTMAP:
4470 4123 ret=control_state[9]?10000:0;
4471 4123 break;
4472
4473 case INPUTUP:
4474 1334804 ret=control_state[0]?10000:0;
4475 1334804 break;
4476
4477 case INPUTDOWN:
4478 847912 ret=control_state[1]?10000:0;
4479 847912 break;
4480
4481 case INPUTLEFT:
4482 1328070 ret=control_state[2]?10000:0;
4483 1328070 break;
4484
4485 case INPUTRIGHT:
4486 1370269 ret=control_state[3]?10000:0;
4487 1370269 break;
4488
4489 case INPUTA:
4490 5693944 ret=control_state[4]?10000:0;
4491 5693944 break;
4492
4493 case INPUTB:
4494 5182994 ret=control_state[5]?10000:0;
4495 5182994 break;
4496
4497 case INPUTL:
4498 3135646 ret=control_state[7]?10000:0;
4499 3135646 break;
4500
4501 case INPUTR:
4502 3131387 ret=control_state[8]?10000:0;
4503 3131387 break;
4504
4505 case INPUTEX1:
4506 119289 ret=control_state[10]?10000:0;
4507 119289 break;
4508
4509 case INPUTEX2:
4510 119580 ret=control_state[11]?10000:0;
4511 119580 break;
4512
4513 case INPUTEX3:
4514 23391 ret=control_state[12]?10000:0;
4515 23391 break;
4516
4517 case INPUTEX4:
4518 23391 ret=control_state[13]?10000:0;
4519 23391 break;
4520
4521 case INPUTAXISUP:
4522 ret=control_state[14]?10000:0;
4523 break;
4524
4525 case INPUTAXISDOWN:
4526 ret=control_state[15]?10000:0;
4527 break;
4528
4529 case INPUTAXISLEFT:
4530 ret=control_state[16]?10000:0;
4531 break;
4532
4533 case INPUTAXISRIGHT:
4534 ret=control_state[17]?10000:0;
4535 break;
4536
4537 case INPUTMOUSEX:
4538 {
4539 766680 ret=get_mouse_state(0)*10000;
4540 766680 break;
4541 }
4542
4543 case INPUTMOUSEY:
4544 {
4545 766680 int32_t mousequakeoffset = 56+((int32_t)(zc::math::Sin((double)(quakeclk*int64_t(2)-frame))*4));
4546
3/4
✓ Branch 0 taken 17451 times.
✓ Branch 1 taken 749229 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 749229 times.
766680 int32_t tempoffset = (quakeclk > 0) ? mousequakeoffset : (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
4547 766680 ret=((get_mouse_state(1)-tempoffset))*10000;
4548 766680 break;
4549 }
4550
4551 case INPUTMOUSEZ:
4552 ret=(get_mouse_state(2))*10000;
4553 break;
4554
4555 case INPUTMOUSEB:
4556 1041016 ret=(get_mouse_state(3))*10000;
4557 1041016 break;
4558
4559 case INPUTPRESSSTART:
4560 728101 ret=button_press[6]?10000:0;
4561 728101 break;
4562
4563 case INPUTPRESSMAP:
4564 276546 ret=button_press[9]?10000:0;
4565 276546 break;
4566
4567 case INPUTPRESSUP:
4568 776094 ret=button_press[0]?10000:0;
4569 776094 break;
4570
4571 case INPUTPRESSDOWN:
4572 715737 ret=button_press[1]?10000:0;
4573 715737 break;
4574
4575 case INPUTPRESSLEFT:
4576 557304 ret=button_press[2]?10000:0;
4577 557304 break;
4578
4579 case INPUTPRESSRIGHT:
4580 514964 ret=button_press[3]?10000:0;
4581 514964 break;
4582
4583 case INPUTPRESSA:
4584 1875584 ret=button_press[4]?10000:0;
4585 1875584 break;
4586
4587 case INPUTPRESSB:
4588 1726419 ret=button_press[5]?10000:0;
4589 1726419 break;
4590
4591 case INPUTPRESSL:
4592 1861217 ret=button_press[7]?10000:0;
4593 1861217 break;
4594
4595 case INPUTPRESSR:
4596 1691656 ret=button_press[8]?10000:0;
4597 1691656 break;
4598
4599 case INPUTPRESSEX1:
4600 873882 ret=button_press[10]?10000:0;
4601 873882 break;
4602
4603 case INPUTPRESSEX2:
4604 873847 ret=button_press[11]?10000:0;
4605 873847 break;
4606
4607 case INPUTPRESSEX3:
4608 541201 ret=button_press[12]?10000:0;
4609 541201 break;
4610
4611 case INPUTPRESSEX4:
4612 541201 ret=button_press[13]?10000:0;
4613 541201 break;
4614
4615 case INPUTPRESSAXISUP:
4616 ret=button_press[14]?10000:0;
4617 break;
4618
4619 case INPUTPRESSAXISDOWN:
4620 ret=button_press[15]?10000:0;
4621 break;
4622
4623 case INPUTPRESSAXISLEFT:
4624 ret=button_press[16]?10000:0;
4625 break;
4626
4627 case INPUTPRESSAXISRIGHT:
4628 ret=button_press[17]?10000:0;
4629 break;
4630
4631 case FFRULE:
4632 {
4633 14 int32_t ruleid = vbound((ri->d[rINDEX]/10000),0,qr_MAX);
4634 14 ret = get_qr(ruleid)?10000:0;
4635 }
4636 14 break;
4637
4638 case BUTTONPRESS:
4639 // DUkey, DDkey, DLkey, DRkey, Akey, Bkey, Skey, Lkey, Rkey, Pkey, Exkey1, Exkey2, Exkey3, Exkey4 };
4640 {
4641 //Read-only
4642 3743 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
4643 3743 ret = button_press[button]?10000:0;
4644 }
4645 3743 break;
4646
4647 case BUTTONINPUT:
4648 {
4649 //Read-only
4650 213 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
4651 213 ret=control_state[button]?10000:0;
4652 }
4653 213 break;
4654
4655 case BUTTONHELD:
4656 {
4657 //Read-only
4658 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
4659 ret = button_hold[button]?10000:0;
4660 }
4661 break;
4662
4663 case RAWKEY:
4664 { //Game->KeyPressed[], read-only
4665 //if ( !keypressed() ) break; //Don;t return values set by setting Hero->Input/Press
4666 //hmm...no, this won;t return properly for modifier keys.
4667 int32_t keyid = ri->d[rINDEX]/10000;
4668 //key = vbound(key,0,n);
4669 bool pressed = key_current_frame[keyid] != 0;
4670 ret = pressed?10000:0;
4671 }
4672 break;
4673
4674 case KEYINPUT:
4675 {
4676 1121 ret = KeyInput[ri->d[rINDEX]/10000] ? 10000 : 0;
4677 1121 break;
4678 }
4679 case KEYPRESS:
4680 {
4681 6774 ret = KeyPress[ri->d[rINDEX]/10000] ? 10000 : 0;
4682 6774 break;
4683 }
4684
4685 case KEYMODIFIERS:
4686 {
4687 ret = (key_shifts*10000);
4688 break;
4689 }
4690
4691 case KEYBINDINGS:
4692 {
4693 int32_t keyid = ri->d[rINDEX]/10000;
4694 switch(keyid)
4695 {
4696 case 0: ret = DUkey * 10000; break;
4697 case 1: ret = DDkey * 10000; break;
4698 case 2: ret = DLkey * 10000; break;
4699 case 3: ret = DRkey * 10000; break;
4700 case 4: ret = Akey * 10000; break;
4701 case 5: ret = Bkey * 10000; break;
4702 case 6: ret = Skey * 10000; break;
4703 case 7: ret = Lkey * 10000; break;
4704 case 8: ret = Rkey * 10000; break;
4705 case 9: ret = Pkey * 10000; /*map*/ break;
4706 case 10: ret = Exkey1 * 10000; break;
4707 case 11: ret = Exkey2 * 10000; break;
4708 case 12: ret = Exkey3 * 10000; break;
4709 case 13: ret = Exkey4 * 10000; break;
4710
4711 default: { Z_scripterrlog("Invalid index [%d] passed to Input->KeyBindings[]\n", keyid); ret = 0; break; }
4712 }
4713 break;
4714 }
4715
4716 case READKEY:
4717 {
4718 //Game->ReadKey(int32_t key), also clears it.
4719 int32_t keyid = ri->d[rINDEX]/10000;
4720 bool pressed = zc_readkey(keyid, true);
4721 ret = pressed?10000:0;
4722 }
4723 break;
4724
4725 case DISABLEKEY:
4726 {
4727 //Input->DisableKey(int32_t key)
4728 int32_t keyid = ri->d[rINDEX]/10000;
4729 ret = disabledKeys[keyid]?10000:0;
4730 break;
4731 }
4732
4733 case DISABLEBUTTON:
4734 {
4735 //Input->DisableButton(int32_t cb)
4736 int32_t cbid = ri->d[rINDEX]/10000;
4737 ret = disable_control[cbid]?10000:0;
4738 break;
4739 }
4740
4741 case JOYPADPRESS:
4742 {
4743 //Checks if a press is from the joypad, not keyboard.
4744 int32_t button = ri->d[rINDEX]/10000;
4745 ret = joybtn(button)?10000:0;
4746 }
4747 break;
4748
4749
4750 case MOUSEARR:
4751 {
4752 468 int32_t indx = (ri->d[rINDEX]/10000);
4753 int32_t rv;
4754
2/7
✗ Branch 0 not taken.
✓ Branch 1 taken 234 times.
✓ Branch 2 taken 234 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
468 switch (indx)
4755 {
4756 case 0: //MouseX
4757 {
4758 234 rv=get_mouse_state(0)*10000;
4759 234 break;
4760 }
4761 case 1: //MouseY
4762 {
4763 234 int32_t mousequakeoffset = 56+((int32_t)(zc::math::Sin((double)(quakeclk*int64_t(2)-frame))*4));
4764
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 234 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 234 times.
234 int32_t tempoffset = (quakeclk > 0) ? mousequakeoffset : (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
4765 234 int32_t topOffset= (112-tempoffset);
4766 234 rv=(get_mouse_state(1)-topOffset)*10000;
4767 234 break;
4768 }
4769 case 2: //MouseZ
4770 {
4771 rv=(get_mouse_state(2))*10000;
4772 break;
4773 }
4774 case 3: //Left Click
4775 {
4776 rv=((get_mouse_state(3)&0x1))*10000;
4777 break;
4778 }
4779 case 4: //Right Click
4780 {
4781 rv=((get_mouse_state(3)&0x2))*10000;
4782 break;
4783 }
4784 case 5: //Middle Click
4785 {
4786 rv=((get_mouse_state(3)&0x4))*10000;
4787 break;
4788 }
4789 default:
4790 {
4791 Z_scripterrlog("Invalid index passed to Input->Mouse[]: %d\n", indx);
4792 rv = -10000;
4793 break;
4794 }
4795 }
4796
4797 //bool pressed = key[keyid] != 0;
4798 //ret = pressed?10000:0;
4799 468 ret = rv;
4800 }
4801 468 break;
4802
4803 ///----------------------------------------------------------------------------------------------------//
4804 //Item Variables
4805 case ITEMSCALE:
4806 if ( get_qr(qr_OLDSPRITEDRAWS) )
4807 {
4808 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
4809 "item->Scale");
4810 ret = -1; break;
4811 }
4812 if(0!=(s=checkItem(ri->itemref)))
4813 {
4814 ret=((int32_t)((item*)(s))->scale)*100.0;
4815 }
4816 break;
4817
4818 case ITEMX:
4819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5848 times.
5848 if(0!=(s=checkItem(ri->itemref)))
4820 {
4821
2/2
✓ Branch 0 taken 2722 times.
✓ Branch 1 taken 3126 times.
5848 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
4822 {
4823 2722 ret=(((item*)(s))->x).getZLong();
4824 2722 }
4825 3126 else ret=((int32_t)((item*)(s))->x)*10000;
4826 5848 }
4827 5848 break;
4828
4829 case ITEMSPRITESCRIPT:
4830 if(0!=(s=checkItem(ri->itemref)))
4831 {
4832 ret=((int32_t)((item*)(s))->script)*10000;
4833 }
4834 break;
4835
4836 case ITEMSPRITEINITD:
4837
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(0!=(s=checkItem(ri->itemref)))
4838 {
4839 24 int32_t a = vbound(ri->d[rINDEX]/10000,0,7);
4840 24 ret=((int32_t)((item*)(s))->initD[a]);
4841 24 }
4842 24 break;
4843
4844 case ITEMFAMILY:
4845 if(0!=(s=checkItem(ri->itemref)))
4846 {
4847 ret=((int32_t)((item*)(s))->family)*10000;
4848 }
4849 break;
4850
4851 case ITEMLEVEL:
4852 if(0!=(s=checkItem(ri->itemref)))
4853 {
4854 ret=((int32_t)((item*)(s))->lvl)*10000;
4855 }
4856 break;
4857
4858 case SPRITEMAXITEM:
4859 {
4860 //No bounds check, as this is a universal function and works from NULL pointers!
4861 ret = items.getMax() * 10000;
4862 break;
4863 }
4864
4865 case ITEMSCRIPTUID:
4866 if(0!=(s=checkItem(ri->itemref)))
4867 {
4868 ret=((int32_t)((item*)(s))->script_UID); //Literal, not *10000
4869 }
4870 break;
4871
4872 case ITEMY:
4873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4206 times.
4206 if(0!=(s=checkItem(ri->itemref)))
4874 {
4875
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 3126 times.
4206 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
4876 {
4877 1080 ret=(((item*)(s))->y).getZLong();
4878 1080 }
4879 else
4880 3126 ret=((int32_t)((item*)(s))->y)*10000;
4881 4206 }
4882 4206 break;
4883
4884 case ITEMZ:
4885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5084 times.
5084 if(0!=(s=checkItem(ri->itemref)))
4886 {
4887
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5082 times.
5084 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
4888 {
4889 2 ret=(((item*)(s))->z).getZLong();
4890 2 }
4891 else
4892 5082 ret=((int32_t)((item*)(s))->z)*10000;
4893 5084 }
4894 5084 break;
4895
4896 case ITEMJUMP:
4897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(0!=(s=checkItem(ri->itemref)))
4898 {
4899 114 ret = ((item*)(s))->fall.getZLong() / -100;
4900
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
4901 114 }
4902 114 break;
4903
4904 case ITEMFAKEJUMP:
4905 if(0!=(s=checkItem(ri->itemref)))
4906 {
4907 ret = ((item*)(s))->fakefall.getZLong() / -100;
4908 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
4909 }
4910 break;
4911
4912 case ITEMDRAWTYPE:
4913 if(0!=(s=checkItem(ri->itemref)))
4914 {
4915 ret=((item*)(s))->drawstyle*10000;
4916 }
4917 break;
4918
4919 case ITEMGRAVITY:
4920 if(0!=(s=checkItem(ri->itemref)))
4921 {
4922 ret=((((item*)(s))->moveflags & FLAG_OBEYS_GRAV) ? 10000 : 0);
4923 }
4924 break;
4925
4926 case ITEMID:
4927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117090 times.
117090 if(0!=(s=checkItem(ri->itemref)))
4928 {
4929 117090 ret=((item*)(s))->id*10000;
4930 117090 }
4931 117090 break;
4932
4933 case ITEMTILE:
4934
1/2
✓ Branch 0 taken 7933 times.
✗ Branch 1 not taken.
7933 if(0!=(s=checkItem(ri->itemref)))
4935 {
4936 7933 ret=((item*)(s))->tile*10000;
4937 7933 }
4938 7933 break;
4939
4940 case ITEMSCRIPTTILE:
4941 if(0!=(s=checkItem(ri->itemref)))
4942 {
4943 ret=((item*)(s))->scripttile*10000;
4944 }
4945 break;
4946
4947 case ITEMSCRIPTFLIP:
4948 if(0!=(s=checkItem(ri->itemref)))
4949 {
4950 ret=((item*)(s))->scriptflip*10000;
4951 }
4952 break;
4953
4954 case ITEMPSTRING:
4955 if(0!=(s=checkItem(ri->itemref)))
4956 {
4957 ret=((item*)(s))->pstring*10000;
4958 }
4959 break;
4960 case ITEMPSTRINGFLAGS:
4961 if(0!=(s=checkItem(ri->itemref)))
4962 {
4963 ret=((item*)(s))->pickup_string_flags*10000;
4964 }
4965 break;
4966 case ITEMOVERRIDEFLAGS:
4967 ret=0;
4968 break;
4969
4970 case ITEMOTILE:
4971
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(0!=(s=checkItem(ri->itemref)))
4972 {
4973 18 ret=((item*)(s))->o_tile*10000;
4974 18 }
4975 18 break;
4976
4977 case ITEMCSET:
4978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7933 times.
7933 if(0!=(s=checkItem(ri->itemref)))
4979 {
4980 7933 ret=(((item*)(s))->o_cset&15)*10000;
4981 7933 }
4982 7933 break;
4983
4984 case ITEMFLASHCSET:
4985 if(0!=(s=checkItem(ri->itemref)))
4986 {
4987 ret=(((item*)(s))->o_cset>>4)*10000;
4988 }
4989 break;
4990
4991 case ITEMFRAMES:
4992 if(0!=(s=checkItem(ri->itemref)))
4993 {
4994 ret=((item*)(s))->frames*10000;
4995 }
4996 break;
4997
4998 case ITEMFRAME:
4999 if(0!=(s=checkItem(ri->itemref)))
5000 {
5001 ret=((item*)(s))->aframe*10000;
5002 }
5003 break;
5004
5005 case ITEMACLK:
5006 if(0!=(s=checkItem(ri->itemref)))
5007 {
5008 ret=((item*)(s))->aclk*10000;
5009 }
5010 break;
5011
5012 case ITEMASPEED:
5013 if(0!=(s=checkItem(ri->itemref)))
5014 {
5015 ret=((item*)(s))->o_speed*10000;
5016 }
5017 break;
5018
5019 case ITEMDELAY:
5020 if(0!=(s=checkItem(ri->itemref)))
5021 {
5022 ret=((item*)(s))->o_delay*10000;
5023 }
5024 break;
5025
5026 case ITEMFLIP:
5027 if(0!=(s=checkItem(ri->itemref)))
5028 {
5029 ret=((item*)(s))->flip*10000;
5030 }
5031 break;
5032
5033 case ITEMFLASH:
5034 if(0!=(s=checkItem(ri->itemref)))
5035 {
5036 ret=((item*)(s))->flash*10000;
5037 }
5038 break;
5039
5040 case ITEMHXOFS:
5041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2552 times.
2552 if(0!=(s=checkItem(ri->itemref)))
5042 {
5043 2552 ret=(((item*)(s))->hxofs)*10000;
5044 2552 }
5045 2552 break;
5046
5047 case ITEMROTATION:
5048 if ( get_qr(qr_OLDSPRITEDRAWS) )
5049 {
5050 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
5051 "item->Rotation");
5052 ret = -1; break;
5053 }
5054 if(0!=(s=checkItem(ri->itemref)))
5055 {
5056 ret=(((item*)(s))->rotation)*10000;
5057 }
5058 break;
5059
5060 case ITEMHYOFS:
5061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2552 times.
2552 if(0!=(s=checkItem(ri->itemref)))
5062 {
5063 2552 ret=(((item*)(s))->hyofs)*10000;
5064 2552 }
5065 2552 break;
5066
5067 case ITEMXOFS:
5068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(0!=(s=checkItem(ri->itemref)))
5069 {
5070 6 ret=((int32_t)(((item*)(s))->xofs))*10000;
5071 6 }
5072 6 break;
5073
5074 case ITEMYOFS:
5075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 if(0!=(s=checkItem(ri->itemref)))
5076 {
5077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 ret=((int32_t)(((item*)(s))->yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)))*10000;
5078 334 }
5079 334 break;
5080
5081 case ITEMSHADOWXOFS:
5082 if(0!=(s=checkItem(ri->itemref)))
5083 {
5084 ret=((int32_t)(((item*)(s))->shadowyofs))*10000;
5085 }
5086 break;
5087
5088 case ITEMSHADOWYOFS:
5089 if(0!=(s=checkItem(ri->itemref)))
5090 {
5091 ret=((int32_t)(((item*)(s))->shadowxofs))*10000;
5092 }
5093 break;
5094
5095
5096 case ITEMZOFS:
5097 if(0!=(s=checkItem(ri->itemref)))
5098 {
5099 ret=((int32_t)(((item*)(s))->zofs))*10000;
5100 }
5101 break;
5102
5103 case ITEMHXSZ:
5104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2552 times.
2552 if(0!=(s=checkItem(ri->itemref)))
5105 {
5106 2552 ret=(((item*)(s))->hit_width)*10000;
5107 2552 }
5108 2552 break;
5109
5110 case ITEMHYSZ:
5111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2552 times.
2552 if(0!=(s=checkItem(ri->itemref)))
5112 {
5113 2552 ret=(((item*)(s))->hit_height)*10000;
5114 2552 }
5115 2552 break;
5116
5117 case ITEMHZSZ:
5118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2542 times.
2542 if(0!=(s=checkItem(ri->itemref)))
5119 {
5120 2542 ret=(((item*)(s))->hzsz)*10000;
5121 2542 }
5122 2542 break;
5123
5124 case ITEMTXSZ:
5125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1300 times.
1300 if(0!=(s=checkItem(ri->itemref)))
5126 {
5127 1300 ret=(((item*)(s))->txsz)*10000;
5128 1300 }
5129 1300 break;
5130
5131 case ITEMTYSZ:
5132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1300 times.
1300 if(0!=(s=checkItem(ri->itemref)))
5133 {
5134 1300 ret=(((item*)(s))->tysz)*10000;
5135 1300 }
5136 1300 break;
5137
5138 case ITEMCOUNT:
5139 685905 ret=(items.Count())*10000;
5140 685905 break;
5141
5142 case GETRENDERTARGET:
5143 ret=(zscriptDrawingRenderTarget->GetCurrentRenderTarget())*10000;
5144 break;
5145
5146 case ITEMEXTEND:
5147 if(0!=(s=checkItem(ri->itemref)))
5148 {
5149 ret=((item*)(s))->extend*10000;
5150 }
5151 break;
5152
5153 case ITEMPICKUP:
5154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19906 times.
19906 if(0!=(s=checkItem(ri->itemref)))
5155 {
5156 19906 ret=((item*)(s))->pickup*10000;
5157 19906 }
5158 19906 break;
5159
5160 case ITEMMISCD:
5161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108294 times.
108294 if(0!=(s=checkItem(ri->itemref)))
5162 {
5163 108294 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
5164 108294 ret=(((item*)(s))->miscellaneous[a]);
5165 108294 }
5166 108294 break;
5167
5168 case ITEMFALLCLK:
5169 if(0!=(s=checkItem(ri->itemref)))
5170 {
5171 ret = ((item*)(s))->fallclk * 10000;
5172 }
5173 break;
5174
5175 case ITEMFALLCMB:
5176 if(0!=(s=checkItem(ri->itemref)))
5177 {
5178 ret = ((item*)(s))->fallCombo * 10000;
5179 }
5180 break;
5181
5182 case ITEMDROWNCLK:
5183 if(0!=(s=checkItem(ri->itemref)))
5184 {
5185 ret = ((item*)(s))->drownclk * 10000;
5186 }
5187 break;
5188
5189 case ITEMDROWNCMB:
5190 if(0!=(s=checkItem(ri->itemref)))
5191 {
5192 ret = ((item*)(s))->drownCombo * 10000;
5193 }
5194 break;
5195
5196 case ITEMFAKEZ:
5197 if(0!=(s=checkItem(ri->itemref)))
5198 {
5199 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
5200 {
5201 ret=(((item*)(s))->fakez).getZLong();
5202 }
5203 else
5204 ret=((int32_t)((item*)(s))->fakez)*10000;
5205 }
5206 break;
5207
5208
5209 case ITEMMOVEFLAGS:
5210 {
5211 if(0!=(s=checkItem(ri->itemref)))
5212 {
5213 int32_t indx = ri->d[rINDEX]/10000;
5214 if(BC::checkBounds(indx, 0, 10, "itemsprite->MoveFlags[]") != SH::_NoError)
5215 ret = 0; //false
5216 else
5217 {
5218 //All bits, in order, of a single byte; just use bitwise
5219 ret = (((item*)(s))->moveflags & (1<<indx)) ? 10000 : 0;
5220 }
5221 }
5222 break;
5223 }
5224
5225 case ITEMGLOWRAD:
5226 if(0!=(s=checkItem(ri->itemref)))
5227 {
5228 ret = ((item*)(s))->glowRad * 10000;
5229 }
5230 break;
5231
5232 case ITEMGLOWSHP:
5233 if(0!=(s=checkItem(ri->itemref)))
5234 {
5235 ret = ((item*)(s))->glowShape * 10000;
5236 }
5237 break;
5238
5239 case ITEMDIR:
5240 if(0!=(s=checkItem(ri->itemref)))
5241 {
5242 ret = ((item*)(s))->dir * 10000;
5243 }
5244 break;
5245
5246 case ITEMENGINEANIMATE:
5247 if(0!=(s=checkItem(ri->itemref)))
5248 {
5249 ret = int32_t(((item*)(s))->do_animation) * 10000;
5250 }
5251 break;
5252
5253 case ITEMSHADOWSPR:
5254 if(0!=(s=checkItem(ri->itemref)))
5255 {
5256 ret = int32_t(((item*)(s))->spr_shadow) * 10000;
5257 }
5258 break;
5259 case ITEMDROPPEDBY:
5260 if(0!=(s=checkItem(ri->itemref)))
5261 {
5262 ret = int32_t(((item*)(s))->from_dropset) * 10000;
5263 }
5264 break;
5265 case ITMSWHOOKED:
5266 if(0!=(s=checkItem(ri->itemref)))
5267 {
5268 ret = s->switch_hooked ? 10000 : 0;
5269 }
5270 break;
5271 case ITEMFORCEGRAB:
5272 if(0!=(s=checkItem(ri->itemref)))
5273 {
5274 ret = ((item*)s)->get_forcegrab() ? 10000 : 0;
5275 }
5276 break;
5277
5278 ///----------------------------------------------------------------------------------------------------//
5279 //Itemdata Variables
5280
5281
5282 case IDATAUSEWPN:
5283 if(unsigned(ri->idata) >= MAXITEMS)
5284 {
5285 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5286 ret = -10000;
5287 break;
5288 }
5289 ret=(itemsbuf[ri->idata].useweapon)*10000;
5290 break;
5291 case IDATAUSEDEF:
5292 if(unsigned(ri->idata) >= MAXITEMS)
5293 {
5294 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5295 ret = -10000;
5296 break;
5297 }
5298 ret=(itemsbuf[ri->idata].usedefence)*10000;
5299 break;
5300 case IDATAWRANGE:
5301 if(unsigned(ri->idata) >= MAXITEMS)
5302 {
5303 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5304 ret = -10000;
5305 break;
5306 }
5307 ret=(itemsbuf[ri->idata].weaprange)*10000;
5308 break;
5309 case IDATAMAGICTIMER:
5310 if(unsigned(ri->idata) >= MAXITEMS)
5311 {
5312 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5313 ret = -10000;
5314 break;
5315 }
5316 ret=(itemsbuf[ri->idata].magiccosttimer[0])*10000;
5317 break;
5318 case IDATAMAGICTIMER2:
5319 if(unsigned(ri->idata) >= MAXITEMS)
5320 {
5321 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5322 ret = -10000;
5323 break;
5324 }
5325 ret=(itemsbuf[ri->idata].magiccosttimer[1])*10000;
5326 break;
5327 case IDATAUSEMVT:
5328 {
5329 if(unsigned(ri->idata) >= MAXITEMS)
5330 {
5331 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5332 ret = -10000;
5333 break;
5334 }
5335 int32_t a = vbound((ri->d[rINDEX] / 10000),0,(ITEM_MOVEMENT_PATTERNS-1));
5336 ret=(itemsbuf[ri->idata].weap_pattern[a])*10000;
5337 }
5338 break;
5339
5340 case IDATADURATION:
5341 if(unsigned(ri->idata) >= MAXITEMS)
5342 {
5343 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5344 ret = -10000;
5345 break;
5346 }
5347 ret=(itemsbuf[ri->idata].weapduration)*10000;
5348 break;
5349
5350 case IDATADUPLICATES:
5351 if(unsigned(ri->idata) >= MAXITEMS)
5352 {
5353 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5354 ret = -10000;
5355 break;
5356 }
5357 ret=(itemsbuf[ri->idata].duplicates)*10000;
5358 break;
5359 case IDATADRAWLAYER:
5360 if(unsigned(ri->idata) >= MAXITEMS)
5361 {
5362 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5363 ret = -10000;
5364 break;
5365 }
5366 ret=(itemsbuf[ri->idata].drawlayer)*10000;
5367 break;
5368 case IDATACOLLECTFLAGS:
5369 if(unsigned(ri->idata) >= MAXITEMS)
5370 {
5371 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5372 ret = 0;
5373 break;
5374 }
5375 ret=(itemsbuf[ri->idata].collectflags)*10000;
5376 break;
5377 case IDATAWEAPONSCRIPT:
5378 if(unsigned(ri->idata) >= MAXITEMS)
5379 {
5380 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5381 ret = -10000;
5382 break;
5383 }
5384 ret=(itemsbuf[ri->idata].weaponscript)*10000;
5385 break;
5386 case IDATAMISCD:
5387 {
5388 if(unsigned(ri->idata) >= MAXITEMS)
5389 {
5390 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5391 ret = -10000;
5392 break;
5393 }
5394 int32_t a = vbound((ri->d[rINDEX] / 10000),0,31);
5395 ret=(itemsbuf[ri->idata].wpn_misc_d[a])*10000;
5396 }
5397 break;
5398 case IDATAWPNINITD:
5399 {
5400 if(unsigned(ri->idata) >= MAXITEMS)
5401 {
5402 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5403 ret = -10000;
5404 break;
5405 }
5406 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
5407 ret=(itemsbuf[ri->idata].weap_initiald[a]);
5408 }
5409 break;
5410 case IDATAWEAPHXOFS:
5411 if(unsigned(ri->idata) >= MAXITEMS)
5412 {
5413 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5414 ret = -10000;
5415 break;
5416 }
5417 ret=(itemsbuf[ri->idata].weap_hxofs)*10000;
5418 break;
5419 case IDATAWEAPHYOFS:
5420 if(unsigned(ri->idata) >= MAXITEMS)
5421 {
5422 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5423 ret = -10000;
5424 break;
5425 }
5426 ret=(itemsbuf[ri->idata].weap_hyofs)*10000;
5427 break;
5428 case IDATAWEAPHXSZ:
5429 if(unsigned(ri->idata) >= MAXITEMS)
5430 {
5431 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5432 ret = -10000;
5433 break;
5434 }
5435 ret=(itemsbuf[ri->idata].weap_hxsz)*10000;
5436 break;
5437 case IDATAWEAPHYSZ:
5438 if(unsigned(ri->idata) >= MAXITEMS)
5439 {
5440 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5441 ret = -10000;
5442 break;
5443 }
5444 ret=(itemsbuf[ri->idata].weap_hysz)*10000;
5445 break;
5446 case IDATAWEAPHZSZ:
5447 if(unsigned(ri->idata) >= MAXITEMS)
5448 {
5449 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5450 ret = -10000;
5451 break;
5452 }
5453 ret=(itemsbuf[ri->idata].weap_hzsz)*10000;
5454 break;
5455 case IDATAWEAPXOFS:
5456 if(unsigned(ri->idata) >= MAXITEMS)
5457 {
5458 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5459 ret = -10000;
5460 break;
5461 }
5462 ret=(itemsbuf[ri->idata].weap_xofs)*10000;
5463 break;
5464 case IDATAWEAPYOFS:
5465 if(unsigned(ri->idata) >= MAXITEMS)
5466 {
5467 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5468 ret = -10000;
5469 break;
5470 }
5471 ret=(itemsbuf[ri->idata].weap_yofs)*10000;
5472 break;
5473 case IDATAHXOFS:
5474 if(unsigned(ri->idata) >= MAXITEMS)
5475 {
5476 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5477 ret = -10000;
5478 break;
5479 }
5480 ret=(itemsbuf[ri->idata].hxofs)*10000;
5481 break;
5482 case IDATAHYOFS:
5483 if(unsigned(ri->idata) >= MAXITEMS)
5484 {
5485 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5486 ret = -10000;
5487 break;
5488 }
5489 ret=(itemsbuf[ri->idata].hyofs)*10000;
5490 break;
5491 case IDATAHXSZ:
5492 if(unsigned(ri->idata) >= MAXITEMS)
5493 {
5494 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5495 ret = -10000;
5496 break;
5497 }
5498 ret=(itemsbuf[ri->idata].hxsz)*10000;
5499 break;
5500 case IDATAHYSZ:
5501 if(unsigned(ri->idata) >= MAXITEMS)
5502 {
5503 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5504 ret = -10000;
5505 break;
5506 }
5507 ret=(itemsbuf[ri->idata].hysz)*10000;
5508 break;
5509 case IDATAHZSZ:
5510 if(unsigned(ri->idata) >= MAXITEMS)
5511 {
5512 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5513 ret = -10000;
5514 break;
5515 }
5516 ret=(itemsbuf[ri->idata].hzsz)*10000;
5517 break;
5518 case IDATADXOFS:
5519 if(unsigned(ri->idata) >= MAXITEMS)
5520 {
5521 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5522 ret = -10000;
5523 break;
5524 }
5525 ret=(itemsbuf[ri->idata].xofs)*10000;
5526 break;
5527 case IDATADYOFS:
5528 if(unsigned(ri->idata) >= MAXITEMS)
5529 {
5530 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5531 ret = -10000;
5532 break;
5533 }
5534 ret=(itemsbuf[ri->idata].yofs)*10000;
5535 break;
5536 case IDATATILEW:
5537 if(unsigned(ri->idata) >= MAXITEMS)
5538 {
5539 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5540 ret = -10000;
5541 break;
5542 }
5543 ret=(itemsbuf[ri->idata].tilew)*10000;
5544 break;
5545 case IDATATILEH:
5546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(unsigned(ri->idata) >= MAXITEMS)
5547 {
5548 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5549 ret = -10000;
5550 break;
5551 }
5552 53 ret=(itemsbuf[ri->idata].tileh)*10000;
5553 53 break;
5554 case IDATAPICKUP:
5555 if(unsigned(ri->idata) >= MAXITEMS)
5556 {
5557 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5558 ret = -10000;
5559 break;
5560 }
5561 ret=(itemsbuf[ri->idata].pickup)*10000;
5562 break;
5563 case IDATAOVERRIDEFL:
5564 if(unsigned(ri->idata) >= MAXITEMS)
5565 {
5566 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5567 ret = 0;
5568 break;
5569 }
5570 ret=(itemsbuf[ri->idata].overrideFLAGS)*10000;
5571 break;
5572
5573 case IDATATILEWWEAP:
5574 if(unsigned(ri->idata) >= MAXITEMS)
5575 {
5576 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5577 ret = -10000;
5578 break;
5579 }
5580 ret=(itemsbuf[ri->idata].weap_tilew)*10000;
5581 break;
5582 case IDATATILEHWEAP:
5583 if(unsigned(ri->idata) >= MAXITEMS)
5584 {
5585 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5586 ret = -10000;
5587 break;
5588 }
5589 ret=(itemsbuf[ri->idata].weap_tileh)*10000;
5590 break;
5591 case IDATAOVERRIDEFLWEAP:
5592 if(unsigned(ri->idata) >= MAXITEMS)
5593 {
5594 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5595 ret = 0;
5596 break;
5597 }
5598 ret=(itemsbuf[ri->idata].weapoverrideFLAGS)*10000;
5599 break;
5600
5601 case IDATAFAMILY:
5602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1751295 times.
1751295 if(unsigned(ri->idata) >= MAXITEMS)
5603 {
5604 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5605 ret = -10000;
5606 break;
5607 }
5608 1751295 ret=(itemsbuf[ri->idata].family)*10000;
5609 1751295 break;
5610
5611 case IDATALEVEL:
5612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14532 times.
14532 if(unsigned(ri->idata) >= MAXITEMS)
5613 {
5614 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5615 ret = -10000;
5616 break;
5617 }
5618 14532 ret=(itemsbuf[ri->idata].fam_type)*10000;
5619 14532 break;
5620
5621 case IDATAKEEP:
5622 ret = item_flag(ITEM_GAMEDATA);
5623 break;
5624
5625 case IDATAAMOUNT:
5626 {
5627 if(unsigned(ri->idata) >= MAXITEMS)
5628 {
5629 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5630 ret = -10000;
5631 break;
5632 }
5633 int32_t v = itemsbuf[ri->idata].amount;
5634 ret = ((v&0x4000)?-1:1)*(v & 0x3FFF)*10000;
5635 break;
5636 }
5637 case IDATAGRADUAL:
5638 {
5639 if(unsigned(ri->idata) >= MAXITEMS)
5640 {
5641 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5642 ret = -10000;
5643 break;
5644 }
5645 ret = (itemsbuf[ri->idata].amount&0x8000) ? 10000 : 0;
5646 break;
5647 }
5648 case IDATACONSTSCRIPT:
5649 ret = item_flag(ITEM_PASSIVESCRIPT);
5650 break;
5651 case IDATASSWIMDISABLED:
5652 ret = item_flag(ITEM_SIDESWIM_DISABLED);
5653 break;
5654 case IDATABUNNYABLE:
5655 ret = item_flag(ITEM_BUNNY_ENABLED);
5656 break;
5657 case IDATAJINXIMMUNE:
5658 ret = item_flag(ITEM_JINX_IMMUNE);
5659 break;
5660 case IDATAJINXSWAP:
5661 ret = item_flag(ITEM_FLIP_JINX);
5662 break;
5663
5664 case IDATASETMAX:
5665 if(unsigned(ri->idata) >= MAXITEMS)
5666 {
5667 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5668 ret = -10000;
5669 break;
5670 }
5671 ret=(itemsbuf[ri->idata].setmax)*10000;
5672 break;
5673
5674 case IDATAMAX:
5675 if(unsigned(ri->idata) >= MAXITEMS)
5676 {
5677 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5678 ret = -10000;
5679 break;
5680 }
5681 ret=(itemsbuf[ri->idata].max)*10000;
5682 break;
5683
5684 case IDATACOUNTER:
5685 if(unsigned(ri->idata) >= MAXITEMS)
5686 {
5687 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5688 ret = -10000;
5689 break;
5690 }
5691 ret=(itemsbuf[ri->idata].count)*10000;
5692 break;
5693
5694 case IDATAPSOUND:
5695 if(unsigned(ri->idata) >= MAXITEMS)
5696 {
5697 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5698 ret = -10000;
5699 break;
5700 }
5701 ret=(itemsbuf[ri->idata].playsound)*10000;
5702 break;
5703 case IDATAUSESOUND:
5704 if(unsigned(ri->idata) >= MAXITEMS)
5705 {
5706 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5707 ret = -10000;
5708 break;
5709 }
5710 ret=(itemsbuf[ri->idata].usesound)*10000;
5711 break;
5712
5713 case IDATAUSESOUND2:
5714 if(unsigned(ri->idata) >= MAXITEMS)
5715 {
5716 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5717 ret = -10000;
5718 break;
5719 }
5720 ret=(itemsbuf[ri->idata].usesound2)*10000;
5721 break;
5722
5723 case IDATAPOWER:
5724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(unsigned(ri->idata) >= MAXITEMS)
5725 {
5726 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5727 ret = -10000;
5728 break;
5729 }
5730 140 ret=(itemsbuf[ri->idata].power)*10000;
5731 140 break;
5732
5733 //Get the ID of an item.
5734 case IDATAID:
5735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1765 times.
1765 if(unsigned(ri->idata) >= MAXITEMS)
5736 {
5737 //Don't error here //Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5738 ret = -10000;
5739 break;
5740 }
5741 1765 ret=ri->idata*10000;
5742 1765 break;
5743
5744 //Get the script assigned to an item (active)
5745 case IDATASCRIPT:
5746 if(unsigned(ri->idata) >= MAXITEMS)
5747 {
5748 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5749 ret = -10000;
5750 break;
5751 }
5752 ret=(itemsbuf[ri->idata].script)*10000;
5753 break;
5754 case IDATASPRSCRIPT:
5755 if(unsigned(ri->idata) >= MAXITEMS)
5756 {
5757 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5758 ret = -10000;
5759 break;
5760 }
5761 ret=(itemsbuf[ri->idata].sprite_script)*10000;
5762 break;
5763 //Get the ->Attributes[] of an item
5764 case IDATAATTRIB:
5765 {
5766 if(unsigned(ri->idata) >= MAXITEMS)
5767 {
5768 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5769 ret = -10000;
5770 break;
5771 }
5772 int32_t index = vbound(ri->d[rINDEX]/10000,0,9);
5773 switch(index)
5774 {
5775 case 0:
5776 ret=(itemsbuf[ri->idata].misc1)*10000; break;
5777 case 1:
5778 ret=(itemsbuf[ri->idata].misc2)*10000; break;
5779 case 2:
5780 ret=(itemsbuf[ri->idata].misc3)*10000; break;
5781 case 3:
5782 ret=(itemsbuf[ri->idata].misc4)*10000; break;
5783 case 4:
5784 ret=(itemsbuf[ri->idata].misc5)*10000; break;
5785 case 5:
5786 ret=(itemsbuf[ri->idata].misc6)*10000; break;
5787 case 6:
5788 ret=(itemsbuf[ri->idata].misc7)*10000; break;
5789 case 7:
5790 ret=(itemsbuf[ri->idata].misc8)*10000; break;
5791 case 8:
5792 ret=(itemsbuf[ri->idata].misc9)*10000; break;
5793 case 9:
5794 ret=(itemsbuf[ri->idata].misc10)*10000; break;
5795 default:
5796 ret = -10000; break;
5797 }
5798
5799 break;
5800 }
5801 //Get the ->Sprite[] of an item.
5802 case IDATASPRITE:
5803 {
5804 if(unsigned(ri->idata) >= MAXITEMS)
5805 {
5806 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5807 ret = -10000;
5808 break;
5809 }
5810 int32_t index = vbound(ri->d[rINDEX]/10000,0,9);
5811 switch(index)
5812 {
5813 case 0:
5814 ret=(itemsbuf[ri->idata].wpn)*10000; break;
5815 case 1:
5816 ret=(itemsbuf[ri->idata].wpn2)*10000; break;
5817 case 2:
5818 ret=(itemsbuf[ri->idata].wpn3)*10000; break;
5819 case 3:
5820 ret=(itemsbuf[ri->idata].wpn4)*10000; break;
5821 case 4:
5822 ret=(itemsbuf[ri->idata].wpn5)*10000; break;
5823 case 5:
5824 ret=(itemsbuf[ri->idata].wpn6)*10000; break;
5825 case 6:
5826 ret=(itemsbuf[ri->idata].wpn7)*10000; break;
5827 case 7:
5828 ret=(itemsbuf[ri->idata].wpn8)*10000; break;
5829 case 8:
5830 ret=(itemsbuf[ri->idata].wpn9)*10000; break;
5831 case 9:
5832 ret=(itemsbuf[ri->idata].wpn10)*10000; break;
5833 default:
5834 ret = -10000; break;
5835 }
5836
5837 break;
5838 }
5839 //Hero TIle modifier
5840 case IDATALTM:
5841 if(unsigned(ri->idata) >= MAXITEMS)
5842 {
5843 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5844 ret = 0;
5845 break;
5846 }
5847 ret=(itemsbuf[ri->idata].ltm)*10000;
5848 break;
5849 //Pickup script
5850 case IDATAPSCRIPT:
5851 if(unsigned(ri->idata) >= MAXITEMS)
5852 {
5853 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5854 ret = -10000;
5855 break;
5856 }
5857 ret=(itemsbuf[ri->idata].collect_script)*10000;
5858 break;
5859 //Pickup string
5860 case IDATAPSTRING:
5861 if(unsigned(ri->idata) >= MAXITEMS)
5862 {
5863 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5864 ret = -10000;
5865 break;
5866 }
5867 ret=(itemsbuf[ri->idata].pstring)*10000;
5868 break;
5869 case IDATAPFLAGS:
5870 if(unsigned(ri->idata) >= MAXITEMS)
5871 {
5872 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5873 ret = 0;
5874 break;
5875 }
5876 ret=(itemsbuf[ri->idata].pickup_string_flags)*10000;
5877 break;
5878 //Magic cost
5879 case IDATAMAGCOST:
5880 if(unsigned(ri->idata) >= MAXITEMS)
5881 {
5882 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5883 ret = -10000;
5884 break;
5885 }
5886 ret=(itemsbuf[ri->idata].cost_amount[0])*10000;
5887 break;
5888 case IDATACOST2:
5889 if(unsigned(ri->idata) >= MAXITEMS)
5890 {
5891 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5892 ret = -10000;
5893 break;
5894 }
5895 ret=(itemsbuf[ri->idata].cost_amount[1])*10000;
5896 break;
5897 //cost counter ref
5898 case IDATACOSTCOUNTER:
5899 if(unsigned(ri->idata) >= MAXITEMS)
5900 {
5901 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5902 ret = -10000;
5903 break;
5904 }
5905 ret=(itemsbuf[ri->idata].cost_counter[0])*10000;
5906 break;
5907 case IDATACOSTCOUNTER2:
5908 if(unsigned(ri->idata) >= MAXITEMS)
5909 {
5910 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5911 ret = -10000;
5912 break;
5913 }
5914 ret=(itemsbuf[ri->idata].cost_counter[1])*10000;
5915 break;
5916 //Min Hearts to Pick Up
5917 case IDATAMINHEARTS:
5918 if(unsigned(ri->idata) >= MAXITEMS)
5919 {
5920 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5921 ret = -10000;
5922 break;
5923 }
5924 ret=(itemsbuf[ri->idata].pickup_hearts)*10000;
5925 break;
5926 //Tile used by the item
5927 case IDATATILE:
5928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55501 times.
55501 if(unsigned(ri->idata) >= MAXITEMS)
5929 {
5930 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5931 ret = -10000;
5932 break;
5933 }
5934 55501 ret=(itemsbuf[ri->idata].tile)*10000;
5935 55501 break;
5936 //itemdata->Flash
5937 case IDATAMISC:
5938 if(unsigned(ri->idata) >= MAXITEMS)
5939 {
5940 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5941 ret = -10000;
5942 break;
5943 }
5944 ret=(itemsbuf[ri->idata].misc_flags)*10000;
5945 break;
5946 //->CSet
5947 case IDATACSET:
5948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55501 times.
55501 if(unsigned(ri->idata) >= MAXITEMS)
5949 {
5950 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5951 ret = -10000;
5952 break;
5953 }
5954 55501 ret=(itemsbuf[ri->idata].csets)*10000;
5955 55501 break;
5956 //->A.Frames
5957 case IDATAFRAMES:
5958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63041 times.
63041 if(unsigned(ri->idata) >= MAXITEMS)
5959 {
5960 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5961 ret = -10000;
5962 break;
5963 }
5964 63041 ret=(itemsbuf[ri->idata].frames)*10000;
5965 63041 break;
5966 /*
5967 case IDATAFRAME:
5968 ret=(itemsbuf[ri->idata].frame)*10000;
5969 break;
5970 */
5971 //->A.Speed
5972 case IDATAASPEED:
5973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142873 times.
142873 if(unsigned(ri->idata) >= MAXITEMS)
5974 {
5975 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5976 ret = -10000;
5977 break;
5978 }
5979 142873 ret=(itemsbuf[ri->idata].speed)*10000;
5980 142873 break;
5981 //->Delay
5982 case IDATADELAY:
5983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74538 times.
74538 if(unsigned(ri->idata) >= MAXITEMS)
5984 {
5985 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5986 ret = -10000;
5987 break;
5988 }
5989 74538 ret=(itemsbuf[ri->idata].delay)*10000;
5990 74538 break;
5991 // teo of this item upgrades
5992 case IDATACOMBINE:
5993 ret = item_flag(ITEM_COMBINE);
5994 break;
5995 //Use item, and get the lower level one
5996 case IDATADOWNGRADE:
5997 ret = item_flag(ITEM_DOWNGRADE);
5998 break;
5999 //Only validate the cost, don't charge it
6000 case IDATAVALIDATE:
6001 ret = item_flag(ITEM_VALIDATEONLY);
6002 break;
6003 case IDATAVALIDATE2:
6004 ret = item_flag(ITEM_VALIDATEONLY2);
6005 break;
6006 //->Flags[5]
6007 case IDATAFLAGS:
6008 {
6009 if(unsigned(ri->idata) >= MAXITEMS)
6010 {
6011 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
6012 ret = 0;
6013 break;
6014 }
6015 int32_t index = ri->d[rINDEX]/10000;
6016 switch(index)
6017 {
6018 case 0:
6019 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG1)?10000:0; break;
6020 case 1:
6021 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG2)?10000:0; break;
6022 case 2:
6023 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG3)?10000:0; break;
6024 case 3:
6025 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG4)?10000:0; break;
6026 case 4:
6027 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG5)?10000:0; break;
6028 case 5:
6029 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG6)?10000:0; break;
6030 case 6:
6031 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG7)?10000:0; break;
6032 case 7:
6033 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG8)?10000:0; break;
6034 case 8:
6035 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG9)?10000:0; break;
6036 case 9:
6037 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG10)?10000:0; break;
6038 case 10:
6039 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG11)?10000:0; break;
6040 case 11:
6041 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG12)?10000:0; break;
6042 case 12:
6043 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG13)?10000:0; break;
6044 case 13:
6045 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG14)?10000:0; break;
6046 case 14:
6047 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG15)?10000:0; break;
6048 case 15:
6049 ret=(itemsbuf[ri->idata].flags & ITEM_PASSIVESCRIPT)?10000:0; break;
6050
6051
6052 default:
6053 Z_scripterrlog("Invalid itemdata->Flags[] index: %d\n", index);
6054 ret = 0;
6055 break;
6056 }
6057 break;
6058 }
6059
6060 //->Keep Old
6061 case IDATAKEEPOLD:
6062 ret = item_flag(ITEM_KEEPOLD);
6063 break;
6064 //Use rupees instead of magic
6065 case IDATARUPEECOST:
6066 ret = item_flag(ITEM_RUPEE_MAGIC);
6067 break;
6068 //Can be eaten
6069 case IDATAEDIBLE:
6070 ret = item_flag(ITEM_EDIBLE);
6071 break;
6072 //currently unused
6073 case IDATAFLAGUNUSED:
6074 ret = item_flag(ITEM_UNUSED);
6075 break;
6076 //Gain lower level items when collected
6077 case IDATAGAINLOWER:
6078 ret = item_flag(ITEM_GAINOLD);
6079 break;
6080 //Unchanged from master
6081 case IDATAINITDD:
6082 {
6083 int32_t a = ri->d[rINDEX] / 10000;
6084 if(unsigned(ri->idata) >= MAXITEMS)
6085 {
6086 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
6087 ret = -10000;
6088 break;
6089 }
6090
6091 if(BC::checkBounds(a, 0, 7, "itemdata->InitD") != SH::_NoError)
6092 ret = -10000;
6093 else
6094 ret = itemsbuf[ri->idata].initiald[a];
6095 }
6096 break;
6097
6098 ///----------------------------------------------------------------------------------------------------//
6099 //NPC Variables
6100
6101 //Reduces accessing integer members to one line
6102 #define GET_NPC_VAR_INT(member, str) \
6103 { \
6104 if(GuyH::loadNPC(ri->guyref, str) != SH::_NoError) \
6105 ret = -10000; \
6106 else \
6107 ret = GuyH::getNPC()->member * 10000; \
6108 }
6109
6110 case NPCDIR:
6111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77691 times.
77691 if(GuyH::loadNPC(ri->guyref, "npc->Dir") != SH::_NoError)
6112 ret = -10000;
6113 else
6114
1/2
✓ Branch 0 taken 77691 times.
✗ Branch 1 not taken.
77691 ret = zc_max(GuyH::getNPC()->dir * 10000, 0);
6115
6116 77691 break;
6117
6118 case NPCHITDIR:
6119 if(GuyH::loadNPC(ri->guyref, "npc->HitDir") != SH::_NoError)
6120 ret = -10000;
6121 else
6122 ret = (GuyH::getNPC()->hitdir * 10000);
6123
6124 break;
6125
6126 case NPCSLIDECLK:
6127 if(GuyH::loadNPC(ri->guyref, "npc->SlideClock") != SH::_NoError)
6128 ret = -10000;
6129 else
6130 ret = (GuyH::getNPC()->sclk * 10000);
6131
6132 break;
6133
6134 case NPCHALTCLK:
6135 if(GuyH::loadNPC(ri->guyref, "npc->Halt") != SH::_NoError)
6136 ret = -10000;
6137 else
6138 ret = (GuyH::getNPC()->clk2 * 10000);
6139
6140 break;
6141
6142 case NPCFRAME:
6143 if(GuyH::loadNPC(ri->guyref, "npc->Frame") != SH::_NoError)
6144 ret = -10000;
6145 else
6146 ret = (GuyH::getNPC()->clk * 10000);
6147
6148 break;
6149
6150 case NPCMOVESTATUS:
6151 if(GuyH::loadNPC(ri->guyref, "npc->MoveStatus") != SH::_NoError)
6152 ret = -10000;
6153 else
6154 ret = (GuyH::getNPC()->movestatus * 10000);
6155
6156 break;
6157
6158 case NPCFADING:
6159 if(GuyH::loadNPC(ri->guyref, "npc->Fading") != SH::_NoError)
6160 ret = -10000;
6161 else
6162 ret = (GuyH::getNPC()->fading * 10000);
6163
6164 break;
6165
6166 case NPCRATE:
6167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 426414 times.
426414 GET_NPC_VAR_INT(rate, "npc->Rate") break;
6168
6169 case NPCHOMING:
6170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436097 times.
436097 GET_NPC_VAR_INT(homing, "npc->Homing") break;
6171
6172 case NPCFRAMERATE:
6173 GET_NPC_VAR_INT(frate, "npc->ASpeed") break;
6174
6175 case NPCHALTRATE:
6176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410674 times.
410674 GET_NPC_VAR_INT(hrate, "npc->HaltRate") break;
6177
6178 case NPCRANDOM:
6179 GET_NPC_VAR_INT(rate, "npc->Random") break;
6180
6181 case NPCDRAWTYPE:
6182 GET_NPC_VAR_INT(drawstyle, "npc->DrawStyle") break;
6183
6184 case NPCHP:
6185
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5126982 times.
5126984 GET_NPC_VAR_INT(hp, "npc->HP") break;
6186
6187 case NPCORIGINALHP:
6188 GET_NPC_VAR_INT(starting_hp, "npc->OriginalHP") break;
6189
6190 case NPCCOLLDET:
6191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165740 times.
165740 GET_NPC_VAR_INT(scriptcoldet, "npc->ColDetection") break;
6192
6193 case NPCENGINEANIMATE:
6194 GET_NPC_VAR_INT(do_animation, "npc->Animation") break;
6195
6196 case NPCSTUN:
6197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1130026 times.
1130026 GET_NPC_VAR_INT(stunclk, "npc->Stun") break;
6198
6199 case NPCHUNGER:
6200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472577 times.
472577 GET_NPC_VAR_INT(grumble, "npc->Hunger") break;
6201
6202 case NPCWEAPSPRITE:
6203 GET_NPC_VAR_INT(wpnsprite, "npc->WeaponSprite") break;
6204
6205 case NPCTYPE:
6206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532410 times.
532410 GET_NPC_VAR_INT(family, "npc->Type") break;
6207
6208 case NPCDP:
6209
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3165 times.
3169 GET_NPC_VAR_INT(dp, "npc->Damage") break;
6210
6211 case NPCWDP:
6212
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 12956 times.
13200 GET_NPC_VAR_INT(wdp, "npc->WeaponDamage") break;
6213
6214 case NPCOTILE:
6215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5408 times.
5408 GET_NPC_VAR_INT(o_tile, "npc->OriginalTile") break;
6216
6217 case NPCTILE:
6218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39139 times.
39139 GET_NPC_VAR_INT(tile, "npc->Tile") break;
6219
6220 case NPCSCRIPTTILE:
6221 GET_NPC_VAR_INT(scripttile, "npc->ScriptTile") break;
6222
6223 case NPCSCRIPTFLIP:
6224 GET_NPC_VAR_INT(scriptflip, "npc->ScriptFlip") break;
6225
6226 case NPCWEAPON:
6227
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 GET_NPC_VAR_INT(wpn, "npc->Weapon") break;
6228
6229 case NPCITEMSET:
6230 GET_NPC_VAR_INT(item_set, "npc->ItemSet") break;
6231
6232 case NPCCSET:
6233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17988 times.
17988 GET_NPC_VAR_INT(cs, "npc->CSet") break;
6234
6235 case NPCBOSSPAL:
6236 GET_NPC_VAR_INT(bosspal, "npc->BossPal") break;
6237
6238 case NPCBGSFX:
6239 GET_NPC_VAR_INT(bgsfx, "npc->SFX") break;
6240
6241 case NPCEXTEND:
6242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6086 times.
6086 GET_NPC_VAR_INT(extend, "npc->Extend") break;
6243
6244 case NPCHXOFS:
6245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383015 times.
383015 GET_NPC_VAR_INT(hxofs, "npc->HitXOffset") break;
6246
6247 case NPCHYOFS:
6248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383015 times.
383015 GET_NPC_VAR_INT(hyofs, "npc->HitYOffset") break;
6249
6250 case NPCHXSZ:
6251
1/2
✓ Branch 0 taken 427914 times.
✗ Branch 1 not taken.
427914 GET_NPC_VAR_INT(hit_width, "npc->HitWidth") break;
6252
6253 case NPCHYSZ:
6254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 427914 times.
427914 GET_NPC_VAR_INT(hit_height, "npc->HitHeight") break;
6255
6256 case NPCHZSZ:
6257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226198 times.
226198 GET_NPC_VAR_INT(hzsz, "npc->HitZHeight") break;
6258
6259 case NPCROTATION:
6260 if ( get_qr(qr_OLDSPRITEDRAWS) )
6261 {
6262 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
6263 "npc->Rotation");
6264 ret = -1; break;
6265 }
6266 GET_NPC_VAR_INT(rotation, "npc->Rotation") break;
6267
6268 case NPCTXSZ:
6269
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1504871 times.
1505295 GET_NPC_VAR_INT(txsz, "npc->TileWidth") break;
6270
6271 case NPCTYSZ:
6272
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1486996 times.
1487420 GET_NPC_VAR_INT(tysz, "npc->TileHeight") break;
6273
6274 //And zfix
6275 #define GET_NPC_VAR_FIX(member, str) \
6276 { \
6277 if(GuyH::loadNPC(ri->guyref, str) != SH::_NoError) \
6278 { \
6279 ret = -10000; \
6280 break; \
6281 } \
6282 else \
6283 ret = (int32_t(GuyH::getNPC()->member) * 10000); \
6284 }
6285
6286 case NPCX:
6287 //GET_NPC_VAR_FIX(x, "npc->X") break;
6288 {
6289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1058433 times.
1058433 if(GuyH::loadNPC(ri->guyref, "X") != SH::_NoError)
6290 {
6291 ret = -10000;
6292 }
6293 else
6294 {
6295
2/2
✓ Branch 0 taken 11123 times.
✓ Branch 1 taken 1047310 times.
1058433 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6296 {
6297 11123 ret = ((GuyH::getNPC()->x).getZLong());
6298 11123 }
6299 else
6300 {
6301 1047310 ret = (int32_t(GuyH::getNPC()->x) * 10000);
6302 }
6303 }
6304 1058433 break;
6305 }
6306
6307 case SPRITEMAXNPC:
6308 {
6309 //No bounds check, as this is a universal function and works from NULL pointers!
6310 ret = guys.getMax() * 10000;
6311 break;
6312 }
6313
6314 case NPCSUBMERGED:
6315 {
6316 if(GuyH::loadNPC(ri->guyref, "Submerged()") != SH::_NoError)
6317 {
6318 ret = -10000;
6319 }
6320 else
6321 {
6322 ret = ((GuyH::getNPC()->isSubmerged()) ? 10000 : 0);
6323
6324 }
6325 break;
6326 }
6327
6328
6329 case NPCY:
6330 //GET_NPC_VAR_FIX(y, "npc->Y") break;
6331 {
6332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1035974 times.
1035974 if(GuyH::loadNPC(ri->guyref, "Y") != SH::_NoError)
6333 {
6334 ret = -10000;
6335 }
6336 else
6337 {
6338
2/2
✓ Branch 0 taken 11122 times.
✓ Branch 1 taken 1024852 times.
1035974 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6339 {
6340 11122 ret = ((GuyH::getNPC()->y).getZLong());
6341 11122 }
6342 else
6343 {
6344 1024852 ret = (int32_t(GuyH::getNPC()->y) * 10000);
6345 }
6346 }
6347 1035974 break;
6348 }
6349
6350
6351 case NPCZ:
6352 //GET_NPC_VAR_FIX(z, "npc->Z") break;
6353 {
6354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 603415 times.
603415 if(GuyH::loadNPC(ri->guyref, "Z") != SH::_NoError)
6355 {
6356 ret = -10000;
6357 }
6358 else
6359 {
6360
2/2
✓ Branch 0 taken 558 times.
✓ Branch 1 taken 602857 times.
603415 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6361 {
6362 558 ret = ((GuyH::getNPC()->z).getZLong());
6363 558 }
6364 else
6365 {
6366 602857 ret = (int32_t(GuyH::getNPC()->z) * 10000);
6367 }
6368 }
6369 603415 break;
6370 }
6371
6372 case NPCXOFS:
6373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2064045 times.
2064045 GET_NPC_VAR_FIX(xofs, "npc->DrawXOffset") break;
6374
6375 case NPCYOFS:
6376
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2065021 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2065021 times.
2065021 GET_NPC_VAR_FIX(yofs, "npc->DrawYOffset") ret-=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)*10000;
6377 2065021 break;
6378 case NPCSHADOWXOFS:
6379 GET_NPC_VAR_FIX(shadowxofs, "npc->ShadowXOffset") break;
6380
6381 case NPCSHADOWYOFS:
6382 GET_NPC_VAR_FIX(shadowyofs, "npc->ShadowYOffset") break;
6383
6384 case NPCTOTALDYOFFS:
6385 {
6386 if(GuyH::loadNPC(ri->guyref, "npc->TotalDYOffset") != SH::_NoError)
6387 {
6388 ret = -10000;
6389 }
6390 else
6391 {
6392 ret = ((int32_t(GuyH::getNPC()->yofs - (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset))
6393 + ((GuyH::getNPC()->switch_hooked && Hero.switchhookstyle == swRISE)
6394 ? -(8-(abs(Hero.switchhookclk-32)/4)) : 0)) * 10000);
6395 }
6396 break;
6397 }
6398
6399 case NPCZOFS:
6400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2064017 times.
2064017 GET_NPC_VAR_FIX(zofs, "npc->DrawZOffset") break;
6401
6402 //These variables are all different to the templates (casting for jump and step is slightly non-standard)
6403 case NPCJUMP:
6404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75623 times.
75623 if(GuyH::loadNPC(ri->guyref, "npc->Jump") != SH::_NoError)
6405 ret = -10000;
6406 else
6407 {
6408 75623 ret = GuyH::getNPC()->fall.getZLong() / -100;
6409
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 75344 times.
75623 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
6410 }
6411
6412 75623 break;
6413
6414 case NPCFAKEJUMP:
6415 if(GuyH::loadNPC(ri->guyref, "npc->FakeJump") != SH::_NoError)
6416 ret = -10000;
6417 else
6418 {
6419 ret = GuyH::getNPC()->fakefall.getZLong() / -100;
6420 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
6421 }
6422
6423 break;
6424
6425
6426 case NPCSCALE:
6427 if ( get_qr(qr_OLDSPRITEDRAWS) )
6428 {
6429 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
6430 "npc->Scale");
6431 ret = -1; break;
6432 }
6433 if(GuyH::loadNPC(ri->guyref, "npc->Scale") != SH::_NoError)
6434 ret = -10000;
6435 else
6436 ret = (int32_t(GuyH::getNPC()->scale) * 100.0);
6437
6438 break;
6439
6440 case NPCIMMORTAL:
6441 if(GuyH::loadNPC(ri->guyref, "npc->Immortal") != SH::_NoError)
6442 ret = -10000;
6443 else
6444 ret = GuyH::getNPC()->immortal ? 10000 : 0;
6445 break;
6446
6447 case NPCNOSLIDE:
6448 if(GuyH::loadNPC(ri->guyref, "npc->NoSlide") != SH::_NoError)
6449 ret = -10000;
6450 else
6451 ret = (GuyH::getNPC()->knockbackflags & FLAG_NOSLIDE) ? 10000 : 0;
6452 break;
6453
6454 case NPCNOSCRIPTKB:
6455 if(GuyH::loadNPC(ri->guyref, "npc->NoScriptKnockback") != SH::_NoError)
6456 ret = -10000;
6457 else
6458 ret = (GuyH::getNPC()->knockbackflags & FLAG_NOSCRIPTKNOCKBACK) ? 10000 : 0;
6459 break;
6460
6461 case NPCKNOCKBACKSPEED:
6462 if(GuyH::loadNPC(ri->guyref, "npc->SlideSpeed") != SH::_NoError)
6463 ret = -10000;
6464 else
6465 ret = GuyH::getNPC()->knockbackSpeed * 10000;
6466 break;
6467
6468 case NPCSTEP:
6469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527244 times.
527244 if(GuyH::loadNPC(ri->guyref, "npc->Step") != SH::_NoError)
6470 ret = -10000;
6471 else
6472 {
6473
3/4
✓ Branch 0 taken 487718 times.
✓ Branch 1 taken 39526 times.
✓ Branch 2 taken 487718 times.
✗ Branch 3 not taken.
527244 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
6474 {
6475 527244 ret = ( ( (GuyH::getNPC()->step).getZLong() ) * 100 );
6476 527244 }
6477 //old, buggy code replication, round two: Go! -Z
6478 //else ret = ( ( (GuyH::getNPC()->step) * 100.0 ).getZLong() );
6479 else
6480 {
6481 double s2 = ( (GuyH::getNPC()->step).getZLong() );
6482 ret = int32_t(s2*100);
6483 //ret = int32_t( ( (GuyH::getNPC()->step) * 100.0 )) * 10000;
6484 }
6485 //else ret = int32_t(GuyH::getNPC()->step * fix(100.0)) * 10000;
6486
6487 //else
6488 //{
6489 //old, buggy code replication, round THREE: Go! -Z
6490 // double tmp = ( (GuyH::getNPC()->step) ) * 1000000.0;
6491 // ret = (int32_t)tmp;
6492 //}
6493 }
6494
6495 527244 break;
6496
6497 case NPCGRAVITY:
6498 if(GuyH::loadNPC(ri->guyref, "npc->Gravity") != SH::_NoError)
6499 ret = -10000;
6500 else
6501 ret = ((GuyH::getNPC()->moveflags & FLAG_OBEYS_GRAV) ? 10000 : 0);
6502
6503 break;
6504
6505
6506 case NPCID:
6507
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 22518976 times.
22519029 if(GuyH::loadNPC(ri->guyref, "npc->ID") != SH::_NoError)
6508 53 ret = -10000;
6509 else
6510 22518976 ret = (GuyH::getNPC()->id & 0xFFF) * 10000;
6511
6512 22519029 break;
6513
6514 case NPCISCORE:
6515 if(GuyH::loadNPC(ri->guyref, "npc->isCore") != SH::_NoError)
6516 ret = -10000;
6517 else
6518 ret = ((GuyH::getNPC()->isCore) ? 10000 : 0);
6519
6520 break;
6521
6522 case NPCSCRIPTUID:
6523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 598 times.
598 if(GuyH::loadNPC(ri->guyref, "npc->ScriptUID") != SH::_NoError)
6524 ret = -10000;
6525 else
6526 598 ret = ((GuyH::getNPC()->getScriptUID())); //literal, not *10000
6527
6528 598 break;
6529
6530 case NPCPARENTUID:
6531 if(GuyH::loadNPC(ri->guyref, "npc->ParentUID") != SH::_NoError)
6532 ret = -10000;
6533 else
6534 ret = ((GuyH::getNPC()->parent_script_UID)); //literal, not *10000
6535
6536 break;
6537
6538 //case EWPNPARENTUID:
6539 //if(0!=(s=checkEWpn(ri->ewpn, "ScriptUID")))
6540 // ret=(((weapon*)(s))->parent_script_UID); //literal, not *10000
6541
6542
6543 case NPCMFLAGS:
6544
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 3672506 times.
3672930 if(GuyH::loadNPC(ri->guyref, "npc->MiscFlags") != SH::_NoError)
6545 424 ret = -10000;
6546 else
6547 3672506 ret = GuyH::getMFlags() * 10000;
6548
6549 3672930 break;
6550
6551 //Indexed (two checks)
6552 case NPCDEFENSED:
6553 {
6554 167669 int32_t a = ri->d[rINDEX] / 10000;
6555
6556
2/4
✓ Branch 0 taken 167669 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167669 times.
167669 if(GuyH::loadNPC(ri->guyref, "npc->Defense[]") != SH::_NoError ||
6557 167669 BC::checkBounds(a, 0, (edefLAST255), "npc->Defense[]") != SH::_NoError)
6558 ret = -10000;
6559 else
6560 167669 ret = GuyH::getNPC()->defense[a] * 10000;
6561 }
6562 167669 break;
6563
6564 case NPCHITBY:
6565 {
6566 268246 int32_t indx = ri->d[rINDEX] / 10000;
6567
6568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 268246 times.
268246 if(GuyH::loadNPC(ri->guyref, "npc->HitBy[]") != SH::_NoError )
6569 {
6570 ret = -10000; break;
6571 }
6572 else
6573 {
6574
2/3
✓ Branch 0 taken 134123 times.
✓ Branch 1 taken 134123 times.
✗ Branch 2 not taken.
268246 switch(indx)
6575 {
6576 //screen indixes
6577 case 0:
6578 case 1:
6579 case 2:
6580 case 3:
6581 case 8:
6582 case 9:
6583 case 10:
6584 case 11:
6585 case 12:
6586 case 16:
6587 {
6588 134123 ret = GuyH::getNPC()->hitby[indx] * 10000; // * 10000; //do not multiply by 10000! UIDs are not *10000!
6589 134123 break;
6590 }
6591 //UIDs
6592 case 4:
6593 case 5:
6594 case 6:
6595 case 7:
6596 case 13:
6597 case 14:
6598 case 15:
6599 {
6600 134123 ret = GuyH::getNPC()->hitby[indx]; // * 10000; //do not multiply by 10000! UIDs are not *10000!
6601 134123 break;
6602 }
6603 default: { Z_scripterrlog("Invalid index used for npc->HitBy[%d]. /n", indx); ret = -10000; break; }
6604 }
6605 268246 break;
6606 }
6607 }
6608
6609 //2.fuure compat.
6610
6611 case NPCSCRDEFENSED:
6612 {
6613 int32_t a = ri->d[rINDEX] / 10000;
6614
6615 if(GuyH::loadNPC(ri->guyref, "npc->ScriptDefense") != SH::_NoError ||
6616 BC::checkBounds(a, 0, edefSCRIPTDEFS_MAX, "npc->ScriptDefense") != SH::_NoError)
6617 ret = -10000;
6618 else
6619 ret = GuyH::getNPC()->defense[a+edefSCRIPT01] * 10000;
6620 }
6621 break;
6622
6623
6624 case NPCMISCD:
6625 {
6626 11384507 int32_t a = ri->d[rINDEX] / 10000;
6627
6628
3/4
✓ Branch 0 taken 11384468 times.
✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11384468 times.
11384507 if(GuyH::loadNPC(ri->guyref, "npc->Misc") != SH::_NoError ||
6629 11384468 BC::checkMisc32(a, "npc->Misc") != SH::_NoError)
6630 39 ret = -10000;
6631 else
6632 11384468 ret = GuyH::getNPC()->miscellaneous[a];
6633 }
6634 11384507 break;
6635 case NPCINITD:
6636 {
6637 int32_t a = ri->d[rINDEX] / 10000;
6638
6639 if(GuyH::loadNPC(ri->guyref, "npc->InitD[]") != SH::_NoError )
6640 ret = -10000;
6641 else
6642 {
6643 //enemy *e = (enemy*)guys.spr(ri->guyref);
6644 ret = (int32_t)GuyH::getNPC()->initD[a];
6645 }
6646 }
6647 break;
6648
6649 case NPCSCRIPT:
6650 {
6651 if(GuyH::loadNPC(ri->guyref, "npc->Script") != SH::_NoError )
6652 ret = -10000;
6653 else
6654 {
6655 //enemy *e = (enemy*)guys.spr(ri->guyref);
6656 ret = (int32_t)GuyH::getNPC()->script * 10000;
6657 }
6658 }
6659 break;
6660
6661 case NPCDD: //Fized the size of this array. There are 15 total attribs, [0] to [14], not [0] to [9]. -Z
6662 {
6663 6431345 int32_t a = ri->d[rINDEX] / 10000;
6664
6665
2/4
✓ Branch 0 taken 6431345 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6431345 times.
✗ Branch 3 not taken.
6431345 if(GuyH::loadNPC(ri->guyref, "npc->Attributes") != SH::_NoError ||
6666 6431345 BC::checkBounds(a, 0, ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 ? 31 : 15 ), "npc->Attributes") != SH::_NoError)
6667 ret = -10000;
6668 else
6669 6431345 ret = GuyH::getNPCDMisc(a) * 10000;
6670 }
6671 6431345 break;
6672
6673 case NPCINVINC:
6674 if(GuyH::loadNPC(ri->guyref, "npc->InvFrames") != SH::_NoError)
6675 ret = -10000;
6676 else
6677 ret = (int32_t)GuyH::getNPC()->hclk * 10000;
6678
6679 break;
6680
6681 case NPCHASITEM:
6682 if(GuyH::loadNPC(ri->guyref, "npc->HasItem") != SH::_NoError)
6683 ret = 0;
6684 else
6685 ret = GuyH::getNPC()->itemguy?10000:0;
6686
6687 break;
6688
6689 case NPCRINGLEAD:
6690 if(GuyH::loadNPC(ri->guyref, "npc->Ringleader") != SH::_NoError)
6691 ret = 0;
6692 else
6693 ret = GuyH::getNPC()->leader?10000:0;
6694
6695 break;
6696
6697 case NPCSUPERMAN:
6698 if(GuyH::loadNPC(ri->guyref, "npc->Invincible") != SH::_NoError)
6699 ret = -10000;
6700 else
6701 ret = (int32_t)GuyH::getNPC()->superman * 10000;
6702
6703 break;
6704
6705 case NPCSHIELD:
6706 {
6707 int32_t indx = ri->d[rINDEX];
6708 if(GuyH::loadNPC(ri->guyref, "npc->Shield[]") == SH::_NoError)
6709 {
6710 switch(indx)
6711 {
6712 case 0:
6713 {
6714 ret = ((GuyH::getNPC()->flags&inv_front) ? 10000 : 0);
6715 break;
6716 }
6717 case 1:
6718 {
6719 ret = ((GuyH::getNPC()->flags&inv_left) ? 10000 : 0);
6720 break;
6721 }
6722 case 2:
6723 {
6724 ret = ((GuyH::getNPC()->flags&inv_right) ? 10000 : 0);
6725 break;
6726 }
6727 case 3:
6728 {
6729 ret = ((GuyH::getNPC()->flags&inv_back) ? 10000 : 0);
6730 break;
6731 }
6732 case 4: //shield can be broken
6733 {
6734 ret = ((GuyH::getNPC()->flags&guy_bkshield) ? 10000 : 0);
6735 break;
6736 }
6737 default:
6738 {
6739 Z_scripterrlog("Invalid Array Index passed to npc->Shield[]: %d\n", indx);
6740 break;
6741 }
6742 }
6743 }
6744 else
6745 {
6746 ret = -10000;
6747 break;
6748 }
6749 }
6750 break;
6751
6752 case NPCFROZENTILE:
6753 GET_NPC_VAR_INT(frozentile, "npc->FrozenTile"); break;
6754
6755 case NPCFROZENCSET:
6756 GET_NPC_VAR_INT(frozencset, "npc->FrozenCSet"); break;
6757
6758 case NPCFROZEN:
6759 GET_NPC_VAR_INT(frozenclock, "npc->Frozen"); break;
6760
6761
6762 case NPCBEHAVIOUR:
6763 {
6764 if(GuyH::loadNPC(ri->guyref, "npc->Behaviour[]") != SH::_NoError)
6765 {
6766 ret = -10000;
6767 break;
6768 }
6769
6770 int32_t index = vbound(ri->d[rINDEX]/10000,0,4);
6771 switch(index)
6772 {
6773 case 0:
6774 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG1)?10000:0; break;
6775 case 1:
6776 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG2)?10000:0; break;
6777 case 2:
6778 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG3)?10000:0; break;
6779 case 3:
6780 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG4)?10000:0; break;
6781 case 4:
6782 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG5)?10000:0; break;
6783 case 5:
6784 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG6)?10000:0; break;
6785 case 6:
6786 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG7)?10000:0; break;
6787 case 7:
6788 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG8)?10000:0; break;
6789 case 8:
6790 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG9)?10000:0; break;
6791 case 9:
6792 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG10)?10000:0; break;
6793 case 10:
6794 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG11)?10000:0; break;
6795 case 11:
6796 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG12)?10000:0; break;
6797 case 12:
6798 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG13)?10000:0; break;
6799 case 13:
6800 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG14)?10000:0; break;
6801 case 14:
6802 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG15)?10000:0; break;
6803 case 15:
6804 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG16)?10000:0; break;
6805
6806 default:
6807 ret = 0; break;
6808 }
6809
6810 break;
6811 }
6812
6813 case NPCFALLCLK:
6814 if(GuyH::loadNPC(ri->guyref, "npc->Falling") == SH::_NoError)
6815 {
6816 ret = GuyH::getNPC()->fallclk * 10000;
6817 }
6818 break;
6819
6820 case NPCFALLCMB:
6821 if(GuyH::loadNPC(ri->guyref, "npc->FallCombo") == SH::_NoError)
6822 {
6823 ret = GuyH::getNPC()->fallCombo * 10000;
6824 }
6825 break;
6826
6827 case NPCDROWNCLK:
6828 if(GuyH::loadNPC(ri->guyref, "npc->Drowning") == SH::_NoError)
6829 {
6830 ret = GuyH::getNPC()->drownclk * 10000;
6831 }
6832 break;
6833
6834 case NPCDROWNCMB:
6835 if(GuyH::loadNPC(ri->guyref, "npc->DrownCombo") == SH::_NoError)
6836 {
6837 ret = GuyH::getNPC()->drownCombo * 10000;
6838 }
6839 break;
6840
6841 case NPCFAKEZ:
6842 {
6843 if(GuyH::loadNPC(ri->guyref, "FakeZ") != SH::_NoError)
6844 {
6845 ret = -10000;
6846 }
6847 else
6848 {
6849 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6850 {
6851 ret = ((GuyH::getNPC()->fakez).getZLong());
6852 }
6853 else
6854 {
6855 ret = (int32_t(GuyH::getNPC()->fakez) * 10000);
6856 }
6857 }
6858 break;
6859 }
6860
6861 case NPCMOVEFLAGS:
6862 {
6863 if(GuyH::loadNPC(ri->guyref, "npc->MoveFlags[]") == SH::_NoError)
6864 {
6865 int32_t indx = ri->d[rINDEX]/10000;
6866 if(BC::checkBounds(indx, 0, 15, "npc->MoveFlags[]") != SH::_NoError)
6867 ret = 0; //false
6868 else
6869 {
6870 //All bits, in order, of a single byte; just use bitwise
6871 ret = (GuyH::getNPC()->moveflags & (1<<indx)) ? 10000 : 0;
6872 }
6873 }
6874 break;
6875 }
6876
6877 case NPCGLOWRAD:
6878 if(GuyH::loadNPC(ri->guyref, "npc->LightRadius") == SH::_NoError)
6879 {
6880 ret = GuyH::getNPC()->glowRad * 10000;
6881 }
6882 break;
6883
6884 case NPCGLOWSHP:
6885 if(GuyH::loadNPC(ri->guyref, "npc->LightShape") == SH::_NoError)
6886 {
6887 ret = GuyH::getNPC()->glowShape * 10000;
6888 }
6889 break;
6890
6891 case NPCSHADOWSPR:
6892 if(GuyH::loadNPC(ri->guyref, "npc->ShadowSprite") == SH::_NoError)
6893 {
6894 ret = GuyH::getNPC()->spr_shadow * 10000;
6895 }
6896 break;
6897 case NPCSPAWNSPR:
6898 if(GuyH::loadNPC(ri->guyref, "npc->SpawnSprite") == SH::_NoError)
6899 {
6900 ret = GuyH::getNPC()->spr_spawn * 10000;
6901 }
6902 break;
6903 case NPCDEATHSPR:
6904 if(GuyH::loadNPC(ri->guyref, "npc->DeathSprite") == SH::_NoError)
6905 {
6906 ret = GuyH::getNPC()->spr_death * 10000;
6907 }
6908 break;
6909 case NPCSWHOOKED:
6910 if(GuyH::loadNPC(ri->guyref, "npc->SwitchHooked") == SH::_NoError)
6911 {
6912 ret = GuyH::getNPC()->switch_hooked ? 10000 : 0;
6913 }
6914 break;
6915 case NPCCANFLICKER:
6916 if(GuyH::loadNPC(ri->guyref, "npc->InvFlicker") == SH::_NoError)
6917 {
6918 ret = GuyH::getNPC()->getCanFlicker() ? 10000 : 0;
6919 }
6920 break;
6921
6922
6923
6924 ///----------------------------------------------------------------------------------------------------//
6925 //LWeapon Variables
6926 case LWPNSPECIAL:
6927 if(0!=(s=checkLWpn(ri->lwpn,"Special")))
6928 ret=((int32_t)((weapon*)(s))->specialinfo)*10000;
6929
6930
6931 break;
6932
6933 case LWPNSCALE:
6934 if ( get_qr(qr_OLDSPRITEDRAWS) )
6935 {
6936 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
6937 "lweapon->Scale");
6938 ret = -1; break;
6939 }
6940 if(0!=(s=checkLWpn(ri->lwpn,"Scale")))
6941 ret=((int32_t)((weapon*)(s))->scale)*100.0;
6942
6943 break;
6944
6945 case LWPNX:
6946
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 700149 times.
713905 if(0!=(s=checkLWpn(ri->lwpn,"X")))
6947 {
6948
2/2
✓ Branch 0 taken 153140 times.
✓ Branch 1 taken 547009 times.
700149 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6949 {
6950 153140 ret=(((weapon*)(s))->x).getZLong();
6951 153140 }
6952 else
6953 547009 ret=((int32_t)((weapon*)(s))->x)*10000;
6954 700149 }
6955
6956 713905 break;
6957
6958 case SPRITEMAXLWPN:
6959 {
6960 //No bounds check, as this is a universal function and works from NULL pointers!
6961 ret = Lwpns.getMax() * 10000;
6962 break;
6963 }
6964
6965 case LWPNY:
6966
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 695675 times.
709431 if(0!=(s=checkLWpn(ri->lwpn,"Y")))
6967 {
6968
2/2
✓ Branch 0 taken 153140 times.
✓ Branch 1 taken 542535 times.
695675 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6969 {
6970 153140 ret=(((weapon*)(s))->y).getZLong();
6971 153140 }
6972 else
6973 542535 ret=((int32_t)((weapon*)(s))->y)*10000;
6974 695675 }
6975 709431 break;
6976
6977 case LWPNZ:
6978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55748 times.
55748 if(0!=(s=checkLWpn(ri->lwpn,"Z")))
6979 {
6980
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 55746 times.
55748 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6981 {
6982 2 ret=(((weapon*)(s))->z).getZLong();
6983 2 }
6984 else
6985 55746 ret=((int32_t)((weapon*)(s))->z)*10000;
6986 55748 }
6987
6988 55748 break;
6989
6990 case LWPNJUMP:
6991 if(0!=(s=checkLWpn(ri->lwpn,"Jump")))
6992 {
6993 ret = ((weapon*)(s))->fall.getZLong() / -100;
6994 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
6995 }
6996
6997 break;
6998
6999 case LWPNFAKEJUMP:
7000 if(0!=(s=checkLWpn(ri->lwpn,"FakeJump")))
7001 {
7002 ret = ((weapon*)(s))->fakefall.getZLong() / -100;
7003 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
7004 }
7005
7006 break;
7007
7008 case LWPNDIR:
7009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67683 times.
67683 if(0!=(s=checkLWpn(ri->lwpn,"Dir")))
7010 67683 ret=((weapon*)(s))->dir*10000;
7011
7012 67683 break;
7013
7014 case LWPNGRAVITY:
7015 if(0!=(s=checkLWpn(ri->lwpn,"Gravity")))
7016 ret= (((weapon*)(s))->moveflags & FLAG_OBEYS_GRAV) ? 10000 : 0;
7017
7018 break;
7019
7020 case LWPNSTEP:
7021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1329 times.
1329 if(0!=(s=checkLWpn(ri->lwpn,"Step")))
7022 {
7023
3/4
✓ Branch 0 taken 1134 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 1134 times.
✗ Branch 3 not taken.
1329 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
7024 {
7025 1329 ret=((weapon*)s)->step.getZLong() * 100;
7026 1329 }
7027 //old, buggy code replication, round two: Go! -Z
7028 //else ret = ( ( ( ((weapon*)s)->step ) * 100.0 ).getZLong() );
7029
7030 //else
7031 //{
7032 //old, buggy code replication, round THREE: Go! -Z
7033 // double tmp = ( ((weapon*)s)->step.getFloat() ) * 1000000.0;
7034 // ret = (int32_t)tmp;
7035 //}
7036
7037 //old, buggy code replication, round FOUR: Go! -Z
7038 else ret = (int32_t)((float)((weapon*)s)->step * 1000000.0);
7039 1329 }
7040 1329 break;
7041
7042 case LWPNANGLE:
7043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(0!=(s=checkLWpn(ri->lwpn,"Angle")))
7044 2 ret=(int32_t)(((weapon*)(s))->angle*10000);
7045
7046 2 break;
7047
7048 case LWPNDEGANGLE:
7049 if(0!=(s=checkLWpn(ri->lwpn,"DegAngle")))
7050 {
7051 ret=(int32_t)(((weapon*)(s))->angle*(180.0 / PI)*10000);
7052 }
7053
7054 break;
7055
7056 case LWPNVX:
7057 if(0!=(s=checkLWpn(ri->lwpn,"Vx")))
7058 {
7059 if (((weapon*)(s))->angular)
7060 ret = int32_t(zc::math::Cos(((weapon*)s)->angle)*10000.0*((weapon*)s)->step);
7061 else
7062 {
7063 switch(NORMAL_DIR(((weapon*)(s))->dir))
7064 {
7065 case l_up:
7066 case l_down:
7067 case left:
7068 ret = int32_t(-10000.0*((weapon*)s)->step);
7069 break;
7070
7071 case r_down:
7072 case r_up:
7073 case right:
7074 ret = int32_t(10000.0*((weapon*)s)->step);
7075 break;
7076
7077 default:
7078 ret = 0;
7079 break;
7080 }
7081 }
7082 }
7083
7084 break;
7085
7086 case LWPNVY:
7087 if(0!=(s=checkLWpn(ri->lwpn,"Vy")))
7088 {
7089 if (((weapon*)(s))->angular)
7090 ret = int32_t(zc::math::Sin(((weapon*)s)->angle)*10000.0*((weapon*)s)->step);
7091 else
7092 {
7093 switch(NORMAL_DIR(((weapon*)(s))->dir))
7094 {
7095 case l_up:
7096 case r_up:
7097 case up:
7098 ret = int32_t(-10000.0*((weapon*)s)->step);
7099 break;
7100 case l_down:
7101 case r_down:
7102 case down:
7103 ret = int32_t(10000.0*((weapon*)s)->step);
7104 break;
7105
7106 default:
7107 ret = 0;
7108 break;
7109 }
7110 }
7111 }
7112
7113 break;
7114
7115 case LWPNANGULAR:
7116 if(0!=(s=checkLWpn(ri->lwpn,"Angular")))
7117 ret=((weapon*)(s))->angular*10000;
7118
7119 break;
7120
7121 case LWPNAUTOROTATE:
7122 if(0!=(s=checkLWpn(ri->lwpn,"AutoRotate")))
7123 ret=((weapon*)(s))->autorotate*10000;
7124
7125 break;
7126
7127 case LWPNBEHIND:
7128 if(0!=(s=checkLWpn(ri->lwpn,"Behind")))
7129 ret=((weapon*)(s))->behind*10000;
7130
7131 break;
7132
7133 case LWPNDRAWTYPE:
7134 if(0!=(s=checkLWpn(ri->lwpn,"DrawStyle")))
7135 ret=((weapon*)(s))->drawstyle*10000;
7136
7137 break;
7138
7139 case LWPNPOWER:
7140
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 85829 times.
85830 if(0!=(s=checkLWpn(ri->lwpn,"Damage")))
7141 85829 ret=((weapon*)(s))->power*10000;
7142
7143 85830 break;
7144 /*
7145 case LWPNRANGE:
7146 if(0!=(s=checkLWpn(ri->lwpn,"Range")))
7147 ret=((weapon*)(s))->scriptrange*10000;
7148
7149 break;
7150 */
7151 case LWPNDEAD:
7152
1/2
✓ Branch 0 taken 1122 times.
✗ Branch 1 not taken.
1122 if(0!=(s=checkLWpn(ri->lwpn,"DeadState")))
7153 1122 ret=((weapon*)(s))->dead*10000;
7154
7155 1122 break;
7156
7157 case LWPNID:
7158
2/2
✓ Branch 0 taken 13757 times.
✓ Branch 1 taken 3771488 times.
3785245 if(0!=(s=checkLWpn(ri->lwpn,"ID")))
7159 3771488 ret=((weapon*)(s))->id*10000;
7160
7161 3785245 break;
7162
7163 case LWPNTILE:
7164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49772 times.
49772 if(0!=(s=checkLWpn(ri->lwpn,"Tile")))
7165 49772 ret=((weapon*)(s))->tile*10000;
7166
7167 49772 break;
7168
7169 case LWPNSCRIPTTILE:
7170 if(0!=(s=checkLWpn(ri->lwpn,"ScriptTile")))
7171 ret=((weapon*)(s))->scripttile*10000;
7172
7173 break;
7174
7175 case LWPNSCRIPTFLIP:
7176 if(0!=(s=checkLWpn(ri->lwpn,"ScriptFlip")))
7177 ret=((weapon*)(s))->scriptflip*10000;
7178
7179 break;
7180
7181 case LWPNCSET:
7182
1/2
✓ Branch 0 taken 49794 times.
✗ Branch 1 not taken.
49794 if(0!=(s=checkLWpn(ri->lwpn,"CSet")))
7183 49794 ret=((weapon*)(s))->cs*10000;
7184
7185 49794 break;
7186
7187 case LWPNFLASHCSET:
7188 if(0!=(s=checkLWpn(ri->lwpn,"FlashCSet")))
7189 ret=(((weapon*)(s))->o_cset>>4)*10000;
7190
7191 break;
7192
7193 case LWPNFRAMES:
7194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3289 times.
3289 if(0!=(s=checkLWpn(ri->lwpn,"NumFrames")))
7195 3289 ret=((weapon*)(s))->frames*10000;
7196
7197 3289 break;
7198
7199 case LWPNFRAME:
7200 if(0!=(s=checkLWpn(ri->lwpn,"Frame")))
7201 ret=((weapon*)(s))->aframe*10000;
7202
7203 break;
7204
7205 case LWPNASPEED:
7206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3289 times.
3289 if(0!=(s=checkLWpn(ri->lwpn,"ASpeed")))
7207 3289 ret=((weapon*)(s))->o_speed*10000;
7208
7209 3289 break;
7210
7211 case LWPNFLASH:
7212 if(0!=(s=checkLWpn(ri->lwpn,"Flash")))
7213 ret=((weapon*)(s))->flash*10000;
7214
7215 break;
7216
7217 case LWPNFLIP:
7218 if(0!=(s=checkLWpn(ri->lwpn,"Flip")))
7219 ret=((weapon*)(s))->flip*10000;
7220
7221 break;
7222
7223 case LWPNCOUNT:
7224 1094820 ret=Lwpns.Count()*10000;
7225 1094820 break;
7226
7227 case LWPNEXTEND:
7228 if(0!=(s=checkLWpn(ri->lwpn,"Extend")))
7229 ret=((weapon*)(s))->extend*10000;
7230
7231 break;
7232
7233 case LWPNOTILE:
7234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 830567 times.
830567 if(0!=(s=checkLWpn(ri->lwpn,"OriginalTile")))
7235 830567 ret=((weapon*)(s))->o_tile*10000;
7236
7237 830567 break;
7238
7239 case LWPNOCSET:
7240 if(0!=(s=checkLWpn(ri->lwpn,"OriginalCSet")))
7241 ret=(((weapon*)(s))->o_cset&15)*10000;
7242
7243 break;
7244
7245 case LWPNHXOFS:
7246
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 121386 times.
135142 if(0!=(s=checkLWpn(ri->lwpn,"HitXOffset")))
7247 121386 ret=(((weapon*)(s))->hxofs)*10000;
7248
7249 135142 break;
7250
7251 case LWPNHYOFS:
7252
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 118638 times.
132394 if(0!=(s=checkLWpn(ri->lwpn,"HitYOffset")))
7253 118638 ret=(((weapon*)(s))->hyofs)*10000;
7254
7255 132394 break;
7256
7257 case LWPNXOFS:
7258 if(0!=(s=checkLWpn(ri->lwpn,"DrawXOffset")))
7259 ret=((int32_t)(((weapon*)(s))->xofs))*10000;
7260
7261 break;
7262
7263 case LWPNYOFS:
7264 if(0!=(s=checkLWpn(ri->lwpn,"DrawYOffset")))
7265 ret=((int32_t)(((weapon*)(s))->yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)))*10000;
7266
7267 break;
7268
7269 case LWPNSHADOWXOFS:
7270 if(0!=(s=checkLWpn(ri->lwpn,"ShadowXOffset")))
7271 ret=((int32_t)(((weapon*)(s))->shadowxofs))*10000;
7272
7273 break;
7274
7275 case LWPNSHADOWYOFS:
7276 if(0!=(s=checkLWpn(ri->lwpn,"ShadowYOffset")))
7277 ret=((int32_t)(((weapon*)(s))->shadowyofs))*10000;
7278
7279 break;
7280
7281 case LWPNTOTALDYOFFS:
7282 if(0!=(s=checkLWpn(ri->lwpn,"TotalDYOffset")))
7283 ret = ((int32_t)(((weapon*)(s))->yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset))
7284 + ((((weapon*)(s))->switch_hooked && Hero.switchhookstyle == swRISE)
7285 ? -(8-(abs(Hero.switchhookclk-32)/4)) : 0)) * 10000;
7286 break;
7287
7288 case LWPNZOFS:
7289 if(0!=(s=checkLWpn(ri->lwpn,"DrawZOffset")))
7290 ret=((int32_t)(((weapon*)(s))->zofs))*10000;
7291
7292 break;
7293
7294 case LWPNHXSZ:
7295
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 119380 times.
133136 if(0!=(s=checkLWpn(ri->lwpn,"HitWidth")))
7296 119380 ret=(((weapon*)(s))->hit_width)*10000;
7297
7298 133136 break;
7299
7300 case LWPNHYSZ:
7301
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 121335 times.
135091 if(0!=(s=checkLWpn(ri->lwpn,"HitHeight")))
7302 121335 ret=(((weapon*)(s))->hit_height)*10000;
7303
7304 135091 break;
7305
7306 case LWPNHZSZ:
7307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27874 times.
27874 if(0!=(s=checkLWpn(ri->lwpn,"HitZHeight")))
7308 27874 ret=(((weapon*)(s))->hzsz)*10000;
7309
7310 27874 break;
7311
7312 case LWPNTXSZ:
7313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25249 times.
25249 if(0!=(s=checkLWpn(ri->lwpn,"TileWidth")))
7314 25249 ret=(((weapon*)(s))->txsz)*10000;
7315
7316 25249 break;
7317
7318 case LWPNTYSZ:
7319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25249 times.
25249 if(0!=(s=checkLWpn(ri->lwpn,"TileHeight")))
7320 25249 ret=(((weapon*)(s))->tysz)*10000;
7321
7322 25249 break;
7323
7324 case LWPNMISCD:
7325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1553638 times.
1553638 if(0!=(s=checkLWpn(ri->lwpn,"Misc")))
7326 {
7327 1553638 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
7328 1553638 ret=(((weapon*)(s))->miscellaneous[a]);
7329 1553638 }
7330
7331 1553638 break;
7332
7333 case LWPNCOLLDET:
7334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4320 times.
4320 if(0!=(s=checkLWpn(ri->lwpn,"CollDetection")))
7335 4320 ret=(((weapon*)(s))->scriptcoldet)*10000;
7336
7337 4320 break;
7338
7339 case LWPNENGINEANIMATE:
7340 if(0!=(s=checkLWpn(ri->lwpn,"Animation")))
7341 ret=(((weapon*)(s))->do_animation)*10000;
7342
7343 break;
7344
7345 case LWPNPARENT:
7346 if(0!=(s=checkLWpn(ri->lwpn,"Parent")))
7347 ret=(((weapon*)(s))->parentitem)*10000;
7348
7349 break;
7350
7351 case LWPNLEVEL:
7352 if(0!=(s=checkLWpn(ri->lwpn,"Level")))
7353 ret=(((weapon*)(s))->type)*10000;
7354
7355 break;
7356
7357 case LWPNSCRIPT:
7358 if(0!=(s=checkLWpn(ri->lwpn,"Script")))
7359 ret=(((weapon*)(s))->weaponscript)*10000;
7360
7361 break;
7362
7363 case LWPNUSEWEAPON:
7364
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(0!=(s=checkLWpn(ri->lwpn,"Weapon")))
7365 179 ret=(((weapon*)(s))->useweapon)*10000;
7366
7367 179 break;
7368
7369 case LWPNUSEDEFENCE:
7370 if(0!=(s=checkLWpn(ri->lwpn,"Defense")))
7371 ret=(((weapon*)(s))->usedefence)*10000;
7372
7373 break;
7374
7375 case LWPNINITD:
7376 {
7377 180 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
7378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if(0!=(s=checkLWpn(ri->lwpn,"InitD[]")))
7379 {
7380 180 ret=(((weapon*)(s))->weap_initd[a]);
7381 180 }
7382 180 break;
7383 }
7384
7385 case LWEAPONSCRIPTUID:
7386 if(0!=(s=checkLWpn(ri->lwpn,"ScriptUID")))
7387 ret=(((weapon*)(s))->script_UID); //literal, not *10000
7388
7389 break;
7390
7391 case LWPNROTATION:
7392 if ( get_qr(qr_OLDSPRITEDRAWS) )
7393 {
7394 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
7395 "lweapon->Rotation");
7396 ret = -1; break;
7397 }
7398 if(0!=(s=checkLWpn(ri->lwpn,"Rotation")))
7399 ret=((weapon*)(s))->rotation*10000;
7400
7401 break;
7402
7403 case LWPNFALLCLK:
7404 if(0!=(s=checkLWpn(ri->lwpn,"Falling")))
7405 {
7406 ret = ((weapon*)(s))->fallclk * 10000;
7407 }
7408 break;
7409
7410 case LWPNFALLCMB:
7411 if(0!=(s=checkLWpn(ri->lwpn,"FallCombo")))
7412 {
7413 ret = ((weapon*)(s))->fallCombo * 10000;
7414 }
7415 break;
7416
7417 case LWPNDROWNCLK:
7418 if(0!=(s=checkLWpn(ri->lwpn,"Drowning")))
7419 {
7420 ret = ((weapon*)(s))->drownclk * 10000;
7421 }
7422 break;
7423
7424 case LWPNDROWNCMB:
7425 if(0!=(s=checkLWpn(ri->lwpn,"DrownCombo")))
7426 {
7427 ret = ((weapon*)(s))->drownCombo * 10000;
7428 }
7429 break;
7430
7431 case LWPNFAKEZ:
7432 if(0!=(s=checkLWpn(ri->lwpn,"FakeZ")))
7433 {
7434 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
7435 {
7436 ret=(((weapon*)(s))->fakez).getZLong();
7437 }
7438 else
7439 ret=((int32_t)((weapon*)(s))->fakez)*10000;
7440 }
7441 break;
7442
7443 case LWPNMOVEFLAGS:
7444 {
7445 if(0!=(s=checkLWpn(ri->lwpn,"MoveFlags[]")))
7446 {
7447 int32_t indx = ri->d[rINDEX]/10000;
7448 if(BC::checkBounds(indx, 0, 10, "lweapon->MoveFlags[]") != SH::_NoError)
7449 ret = 0; //false
7450 else
7451 {
7452 //All bits, in order, of a single byte; just use bitwise
7453 ret = (((weapon*)(s))->moveflags & (1<<indx)) ? 10000 : 0;
7454 }
7455 }
7456 break;
7457 }
7458 case LWPNFLAGS:
7459 {
7460 if(0!=(s=checkLWpn(ri->lwpn,"Flags[]")))
7461 {
7462 int32_t indx = ri->d[rINDEX]/10000;
7463 if(BC::checkBounds(indx, 0, WFLAG_MAX, "lweapon->Flags[]") != SH::_NoError)
7464 ret = 0; //false
7465 else
7466 {
7467 //All bits, in order, of a single byte; just use bitwise
7468 ret = (((weapon*)(s))->misc_wflags & (1<<indx)) ? 10000 : 0;
7469 }
7470 }
7471 break;
7472 }
7473
7474 case LWPNGLOWRAD:
7475 if(0!=(s=checkLWpn(ri->lwpn,"LightRadius")))
7476 {
7477 ret = ((weapon*)(s))->glowRad * 10000;
7478 }
7479 break;
7480
7481 case LWPNGLOWSHP:
7482 if(0!=(s=checkLWpn(ri->lwpn,"LightShape")))
7483 {
7484 ret = ((weapon*)(s))->glowShape * 10000;
7485 }
7486 break;
7487
7488 case LWPNUNBL:
7489 if(0!=(s=checkLWpn(ri->lwpn,"Unblockable")))
7490 {
7491 ret = ((weapon*)(s))->unblockable * 10000;
7492 }
7493 break;
7494
7495 case LWPNSHADOWSPR:
7496 if(0!=(s=checkLWpn(ri->lwpn,"ShadowSprite")))
7497 {
7498 ret = ((weapon*)(s))->spr_shadow * 10000;
7499 }
7500 break;
7501 case LWSWHOOKED:
7502 if(0!=(s=checkLWpn(ri->lwpn,"SwitchHooked")))
7503 {
7504 ret = s->switch_hooked ? 10000 : 0;
7505 }
7506 break;
7507 case LWPNTIMEOUT:
7508 if(0!=(s=checkLWpn(ri->lwpn,"Timeout")))
7509 {
7510 ret = ((weapon*)(s))->weap_timeout * 10000;
7511 }
7512 break;
7513 case LWPNDEATHITEM:
7514 if(0!=(s=checkLWpn(ri->lwpn,"DeathItem")))
7515 {
7516 ret = ((weapon*)(s))->death_spawnitem * 10000;
7517 }
7518 break;
7519 case LWPNDEATHDROPSET:
7520 if(0!=(s=checkLWpn(ri->lwpn,"DeathDropset")))
7521 {
7522 ret = ((weapon*)(s))->death_spawndropset * 10000;
7523 }
7524 break;
7525 case LWPNDEATHIPICKUP:
7526 if(0!=(s=checkLWpn(ri->lwpn,"DeathItemPFlags")))
7527 {
7528 ret = ((weapon*)(s))->death_item_pflags * 10000;
7529 }
7530 break;
7531 case LWPNDEATHSPRITE:
7532 if(0!=(s=checkLWpn(ri->lwpn,"DeathSprite")))
7533 {
7534 ret = ((weapon*)(s))->death_sprite * 10000;
7535 }
7536 break;
7537 case LWPNDEATHSFX:
7538 if(0!=(s=checkLWpn(ri->lwpn,"DeathSFX")))
7539 {
7540 ret = ((weapon*)(s))->death_sfx * 10000;
7541 }
7542 break;
7543 case LWPNLIFTLEVEL:
7544 if(0!=(s=checkLWpn(ri->lwpn,"LiftLevel")))
7545 {
7546 ret = ((weapon*)(s))->lift_level * 10000;
7547 }
7548 break;
7549 case LWPNLIFTTIME:
7550 if(0!=(s=checkLWpn(ri->lwpn,"LiftTime")))
7551 {
7552 ret = ((weapon*)(s))->lift_time * 10000;
7553 }
7554 break;
7555 case LWPNLIFTHEIGHT:
7556 if(0!=(s=checkLWpn(ri->lwpn,"LiftHeight")))
7557 {
7558 ret = ((weapon*)(s))->lift_height.getZLong();
7559 }
7560 break;
7561
7562 ///----------------------------------------------------------------------------------------------------//
7563 //EWeapon Variables
7564 case EWPNSCALE:
7565 if ( get_qr(qr_OLDSPRITEDRAWS) )
7566 {
7567 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
7568 "eweapon->Scale");
7569 ret = -1; break;
7570 }
7571 if(0!=(s=checkEWpn(ri->ewpn, "Scale")))
7572 ret=((int32_t)((weapon*)(s))->scale)*100.0;
7573
7574 break;
7575
7576 case EWPNX:
7577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1267145 times.
1267145 if(0!=(s=checkEWpn(ri->ewpn, "X")))
7578 {
7579
2/2
✓ Branch 0 taken 148798 times.
✓ Branch 1 taken 1118347 times.
1267145 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
7580 {
7581 148798 ret=(((weapon*)(s))->x).getZLong();
7582 148798 }
7583 else
7584 1118347 ret=((int32_t)((weapon*)(s))->x)*10000;
7585 1267145 }
7586 1267145 break;
7587
7588 case SPRITEMAXEWPN:
7589 {
7590 //No bounds check, as this is a universal function and works from NULL pointers!
7591 ret = Ewpns.getMax() * 10000;
7592 break;
7593 }
7594
7595 case EWPNY:
7596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1266708 times.
1266708 if(0!=(s=checkEWpn(ri->ewpn, "Y")))
7597 {
7598
2/2
✓ Branch 0 taken 148686 times.
✓ Branch 1 taken 1118022 times.
1266708 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
7599 {
7600 148686 ret=(((weapon*)(s))->y).getZLong();
7601 148686 }
7602 else
7603 1118022 ret=((int32_t)((weapon*)(s))->y)*10000;
7604 1266708 }
7605 1266708 break;
7606
7607 case EWPNZ:
7608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63485 times.
63485 if(0!=(s=checkEWpn(ri->ewpn, "Z")))
7609 {
7610
2/2
✓ Branch 0 taken 607 times.
✓ Branch 1 taken 62878 times.
63485 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
7611 {
7612 607 ret=(((weapon*)(s))->z).getZLong();
7613 607 }
7614 else
7615 62878 ret=((int32_t)((weapon*)(s))->z)*10000;
7616 63485 }
7617 63485 break;
7618
7619 case EWPNJUMP:
7620 if(0!=(s=checkEWpn(ri->ewpn, "Jump")))
7621 {
7622 ret = ((weapon*)(s))->fall.getZLong() / -100;
7623 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
7624 }
7625
7626 break;
7627
7628 case EWPNFAKEJUMP:
7629 if(0!=(s=checkEWpn(ri->ewpn, "FakeJump")))
7630 {
7631 ret = ((weapon*)(s))->fakefall.getZLong() / -100;
7632 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
7633 }
7634
7635 break;
7636
7637 case EWPNDIR:
7638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22679 times.
22679 if(0!=(s=checkEWpn(ri->ewpn, "Dir")))
7639 22679 ret=((weapon*)(s))->dir*10000;
7640
7641 22679 break;
7642
7643 case EWPNLEVEL:
7644 if(0!=(s=checkEWpn(ri->ewpn, "Level")))
7645 ret=((weapon*)(s))->type*10000;
7646
7647 break;
7648
7649 case EWPNGRAVITY:
7650 if(0!=(s=checkEWpn(ri->ewpn, "Gravity")))
7651 ret=((((weapon*)(s))->moveflags & FLAG_OBEYS_GRAV) ? 10000 : 0);
7652
7653 break;
7654
7655 case EWPNSTEP:
7656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 362690 times.
362690 if(0!=(s=checkEWpn(ri->ewpn, "Step")))
7657 {
7658
3/4
✓ Branch 0 taken 362528 times.
✓ Branch 1 taken 162 times.
✓ Branch 2 taken 362528 times.
✗ Branch 3 not taken.
362690 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
7659 {
7660 362690 ret=((weapon*)s)->step.getZLong() * 100;
7661 362690 }
7662 //old, buggy code replication, round two: Go! -Z
7663 //else ret = ( ( ( ((weapon*)s)->step ) * 100.0 ).getZLong() );
7664 //old, buggy code replication, round FOUR: Go! -Z
7665 else ret = (int32_t)((float)((weapon*)s)->step * 1000000.0);
7666 362690 }
7667 //else
7668 //{
7669 //old, buggy code replication, round THREE: Go! -Z
7670 // double tmp = ( ((weapon*)s)->step.getFloat() ) * 1000000.0;
7671 // ret = int32_t(tmp);
7672 //}
7673 362690 break;
7674
7675 case EWPNANGLE:
7676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 373525 times.
373525 if(0!=(s=checkEWpn(ri->ewpn,"Angle")))
7677 373525 ret=(int32_t)(((weapon*)(s))->angle*10000);
7678
7679 373525 break;
7680
7681 case EWPNDEGANGLE:
7682 if(0!=(s=checkEWpn(ri->ewpn,"DegAngle")))
7683 {
7684 ret=(int32_t)(((weapon*)(s))->angle*(180.0 / PI)*10000);
7685 }
7686
7687 break;
7688
7689 case EWPNVX:
7690 if(0!=(s=checkEWpn(ri->ewpn,"Vx")))
7691 {
7692 if (((weapon*)(s))->angular)
7693 ret = int32_t(zc::math::Cos(((weapon*)s)->angle)*10000.0*((weapon*)s)->step);
7694 else
7695 {
7696 switch(NORMAL_DIR(((weapon*)(s))->dir))
7697 {
7698 case l_up:
7699 case l_down:
7700 case left:
7701 ret = int32_t(-10000.0*((weapon*)s)->step);
7702 break;
7703 case r_up:
7704 case r_down:
7705 case right:
7706 ret = int32_t(10000.0*((weapon*)s)->step);
7707 break;
7708
7709 default:
7710 ret = 0;
7711 break;
7712 }
7713 }
7714 }
7715
7716 break;
7717
7718 case EWPNVY:
7719 if(0!=(s=checkEWpn(ri->ewpn,"Vy")))
7720 {
7721 if (((weapon*)(s))->angular)
7722 ret = int32_t(zc::math::Sin(((weapon*)s)->angle)*10000.0*((weapon*)s)->step);
7723 else
7724 {
7725 switch(NORMAL_DIR(((weapon*)(s))->dir))
7726 {
7727 case l_up:
7728 case r_up:
7729 case up:
7730 ret = int32_t(-10000.0*((weapon*)s)->step);
7731 break;
7732 case l_down:
7733 case r_down:
7734 case down:
7735 ret = int32_t(10000.0*((weapon*)s)->step);
7736 break;
7737
7738 default:
7739 ret = 0;
7740 break;
7741 }
7742 }
7743 }
7744
7745 break;
7746
7747
7748 case EWPNANGULAR:
7749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68688 times.
68688 if(0!=(s=checkEWpn(ri->ewpn,"Angular")))
7750 68688 ret=((weapon*)(s))->angular*10000;
7751
7752 68688 break;
7753
7754 case EWPNAUTOROTATE:
7755 if(0!=(s=checkEWpn(ri->ewpn,"AutoRotate")))
7756 ret=((weapon*)(s))->autorotate*10000;
7757
7758 break;
7759
7760 case EWPNBEHIND:
7761 if(0!=(s=checkEWpn(ri->ewpn,"Behind")))
7762 ret=((weapon*)(s))->behind*10000;
7763
7764 break;
7765
7766 case EWPNDRAWTYPE:
7767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46359 times.
46359 if(0!=(s=checkEWpn(ri->ewpn,"DrawStyle")))
7768 46359 ret=((weapon*)(s))->drawstyle*10000;
7769
7770 46359 break;
7771
7772 case EWPNPOWER:
7773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90188 times.
90188 if(0!=(s=checkEWpn(ri->ewpn,"Damage")))
7774 90188 ret=((weapon*)(s))->power*10000;
7775
7776 90188 break;
7777
7778 case EWPNDEAD:
7779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if(0!=(s=checkEWpn(ri->ewpn,"DeadState")))
7780 154 ret=((weapon*)(s))->dead*10000;
7781
7782 154 break;
7783
7784 case EWPNID:
7785
1/2
✓ Branch 0 taken 2150394 times.
✗ Branch 1 not taken.
2150394 if(0!=(s=checkEWpn(ri->ewpn,"ID")))
7786 2150394 ret=((weapon*)(s))->id*10000;
7787
7788 2150394 break;
7789
7790 case EWPNTILE:
7791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106032 times.
106032 if(0!=(s=checkEWpn(ri->ewpn,"Tile")))
7792 106032 ret=((weapon*)(s))->tile*10000;
7793
7794 106032 break;
7795
7796 case EWPNSCRIPTTILE:
7797 if(0!=(s=checkEWpn(ri->ewpn,"ScriptTile")))
7798 ret=((weapon*)(s))->scripttile*10000;
7799
7800 break;
7801
7802 case EWPNSCRIPTFLIP:
7803 if(0!=(s=checkEWpn(ri->ewpn,"ScriptFlip")))
7804 ret=((weapon*)(s))->scriptflip*10000;
7805
7806 break;
7807
7808 case EWPNCSET:
7809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24909 times.
24909 if(0!=(s=checkEWpn(ri->ewpn,"CSet")))
7810 24909 ret=((weapon*)(s))->cs*10000;
7811
7812 24909 break;
7813
7814 case EWPNFLASHCSET:
7815 if(0!=(s=checkEWpn(ri->ewpn,"FlashCSet")))
7816 ret=(((weapon*)(s))->o_cset>>4)*10000;
7817
7818 break;
7819
7820 case EWPNFRAMES:
7821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(0!=(s=checkEWpn(ri->ewpn,"NumFrames")))
7822 70 ret=((weapon*)(s))->frames*10000;
7823
7824 70 break;
7825
7826 case EWPNFRAME:
7827 if(0!=(s=checkEWpn(ri->ewpn,"Frame")))
7828 ret=((weapon*)(s))->aframe*10000;
7829
7830 break;
7831
7832 case EWPNASPEED:
7833
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
70 if(0!=(s=checkEWpn(ri->ewpn,"ASpeed")))
7834 70 ret=((weapon*)(s))->o_speed*10000;
7835
7836 70 break;
7837
7838 case EWPNFLASH:
7839 if(0!=(s=checkEWpn(ri->ewpn,"Flash")))
7840 ret=((weapon*)(s))->flash*10000;
7841
7842 break;
7843
7844 case EWPNFLIP:
7845 if(0!=(s=checkEWpn(ri->ewpn,"Flip")))
7846 ret=((weapon*)(s))->flip*10000;
7847
7848 break;
7849
7850 case EWPNROTATION:
7851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 218 times.
218 if ( get_qr(qr_OLDSPRITEDRAWS) )
7852 {
7853 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
7854 "eweapon->Rotation");
7855 break;
7856 }
7857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 218 times.
218 if(0!=(s=checkEWpn(ri->ewpn,"Rotation")))
7858 218 ret=((weapon*)(s))->rotation*10000;
7859
7860 218 break;
7861
7862 case EWPNCOUNT:
7863 1913436 ret=Ewpns.Count()*10000;
7864 1913436 break;
7865
7866 case EWPNEXTEND:
7867 if(0!=(s=checkEWpn(ri->ewpn,"Extend")))
7868 ret=((weapon*)(s))->extend*10000;
7869
7870 break;
7871
7872 case EWPNOTILE:
7873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2925 times.
2925 if(0!=(s=checkEWpn(ri->ewpn,"OriginalTile")))
7874 2925 ret=((weapon*)(s))->o_tile*10000;
7875
7876 2925 break;
7877
7878 case EWPNOCSET:
7879 if(0!=(s=checkEWpn(ri->ewpn,"OriginalCSet")))
7880 ret=(((weapon*)(s))->o_cset&15)*10000;
7881
7882 break;
7883
7884 case EWPNHXOFS:
7885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65540 times.
65540 if(0!=(s=checkEWpn(ri->ewpn,"HitXOffset")))
7886 65540 ret=(((weapon*)(s))->hxofs)*10000;
7887
7888 65540 break;
7889
7890 case EWPNHYOFS:
7891
1/2
✓ Branch 0 taken 65540 times.
✗ Branch 1 not taken.
65540 if(0!=(s=checkEWpn(ri->ewpn,"HitYOffset")))
7892 65540 ret=(((weapon*)(s))->hyofs)*10000;
7893
7894 65540 break;
7895
7896 case EWPNXOFS:
7897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(0!=(s=checkEWpn(ri->ewpn,"DrawXOffset")))
7898 8 ret=((int32_t)(((weapon*)(s))->xofs))*10000;
7899
7900 8 break;
7901
7902 case EWPNYOFS:
7903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(0!=(s=checkEWpn(ri->ewpn,"DrawYOffset")))
7904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=((int32_t)(((weapon*)(s))->yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)))*10000;
7905
7906 96 break;
7907
7908 case EWPNSHADOWXOFS:
7909 if(0!=(s=checkEWpn(ri->ewpn,"ShadowXOffset")))
7910 ret=((int32_t)(((weapon*)(s))->shadowxofs))*10000;
7911
7912 break;
7913
7914 case EWPNSHADOWYOFS:
7915 if(0!=(s=checkEWpn(ri->ewpn,"ShadowYOffset")))
7916 ret=((int32_t)(((weapon*)(s))->shadowyofs))*10000;
7917
7918 break;
7919 case EWPNTOTALDYOFFS:
7920 if(0!=(s=checkLWpn(ri->ewpn,"TotalDYOffset")))
7921 ret = ((int32_t)(((weapon*)(s))->yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset))
7922 + ((((weapon*)(s))->switch_hooked && Hero.switchhookstyle == swRISE)
7923 ? -(8-(abs(Hero.switchhookclk-32)/4)) : 0) * 10000);
7924 break;
7925
7926 case EWPNZOFS:
7927 if(0!=(s=checkEWpn(ri->ewpn,"DrawZOffset")))
7928 ret=((int32_t)(((weapon*)(s))->zofs))*10000;
7929
7930 break;
7931
7932 case EWPNHXSZ:
7933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62523 times.
62523 if(0!=(s=checkEWpn(ri->ewpn,"HitWidth")))
7934 62523 ret=(((weapon*)(s))->hit_width)*10000;
7935
7936 62523 break;
7937
7938 case EWPNHYSZ:
7939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62523 times.
62523 if(0!=(s=checkEWpn(ri->ewpn,"HitHeight")))
7940 62523 ret=(((weapon*)(s))->hit_height)*10000;
7941
7942 62523 break;
7943
7944 case EWPNHZSZ:
7945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12470 times.
12470 if(0!=(s=checkEWpn(ri->ewpn,"HitZHeight")))
7946 12470 ret=(((weapon*)(s))->hzsz)*10000;
7947
7948 12470 break;
7949
7950 case EWPNTXSZ:
7951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24497 times.
24497 if(0!=(s=checkEWpn(ri->ewpn,"TileWidth")))
7952 24497 ret=(((weapon*)(s))->txsz)*10000;
7953
7954 24497 break;
7955
7956 case EWPNTYSZ:
7957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24497 times.
24497 if(0!=(s=checkEWpn(ri->ewpn,"TileHeight")))
7958 24497 ret=(((weapon*)(s))->tysz)*10000;
7959
7960 24497 break;
7961
7962 case EWPNMISCD:
7963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13780500 times.
13780500 if(0!=(s=checkEWpn(ri->ewpn,"Misc")))
7964 {
7965 13780500 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
7966 13780500 ret=(((weapon*)(s))->miscellaneous[a]);
7967 13780500 }
7968
7969 13780500 break;
7970
7971 case EWPNCOLLDET:
7972 if(0!=(s=checkEWpn(ri->ewpn,"CollDetection")))
7973 ret=(((weapon*)(s))->scriptcoldet)*10000;
7974
7975 break;
7976
7977 case EWPNENGINEANIMATE:
7978 if(0!=(s=checkEWpn(ri->ewpn,"Animation")))
7979 ret=(((weapon*)(s))->do_animation)*10000;
7980
7981 break;
7982
7983 case EWPNPARENT:
7984 if(0!=(s=checkEWpn(ri->ewpn, "Parent")))
7985 ret= ((get_qr(qr_OLDEWPNPARENT)) ? (((weapon*)(s))->parentid)*10000 : (((weapon*)(s))->parentid));
7986
7987 break;
7988
7989 case EWEAPONSCRIPTUID:
7990 if(0!=(s=checkEWpn(ri->ewpn, "ScriptUID")))
7991 ret=(((weapon*)(s))->script_UID); //literal, not *10000
7992
7993 break;
7994
7995 case EWPNPARENTUID:
7996 if(0!=(s=checkEWpn(ri->ewpn, "ParentUID")))
7997 ret=(((weapon*)(s))->parent_script_UID); //literal, not *10000
7998
7999 break;
8000
8001 case EWPNSCRIPT:
8002 if(0!=(s=checkEWpn(ri->ewpn,"Script")))
8003 ret=(((weapon*)(s))->weaponscript)*10000;
8004
8005 break;
8006
8007 case EWPNINITD:
8008 {
8009 16680 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
8010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16680 times.
16680 if(0!=(s=checkEWpn(ri->ewpn,"InitD[]")))
8011 {
8012 16680 ret=(((weapon*)(s))->weap_initd[a]);
8013 16680 }
8014 16680 break;
8015 }
8016
8017 case EWPNFALLCLK:
8018 if(0!=(s=checkEWpn(ri->ewpn,"Falling")))
8019 {
8020 ret = ((weapon*)(s))->fallclk * 10000;
8021 }
8022 break;
8023
8024 case EWPNFALLCMB:
8025 if(0!=(s=checkEWpn(ri->ewpn,"FallCombo")))
8026 {
8027 ret = ((weapon*)(s))->fallCombo * 10000;
8028 }
8029 break;
8030
8031 case EWPNDROWNCLK:
8032 if(0!=(s=checkEWpn(ri->ewpn,"Drowning")))
8033 {
8034 ret = ((weapon*)(s))->drownclk * 10000;
8035 }
8036 break;
8037
8038 case EWPNDROWNCMB:
8039 if(0!=(s=checkEWpn(ri->ewpn,"DrownCombo")))
8040 {
8041 ret = ((weapon*)(s))->drownCombo * 10000;
8042 }
8043 break;
8044 case EWPNFAKEZ:
8045 if(0!=(s=checkEWpn(ri->ewpn, "FakeZ")))
8046 {
8047 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
8048 {
8049 ret=(((weapon*)(s))->fakez).getZLong();
8050 }
8051 else
8052 ret=((int32_t)((weapon*)(s))->fakez)*10000;
8053 }
8054 break;
8055
8056 case EWPNMOVEFLAGS:
8057 {
8058 if(0!=(s=checkEWpn(ri->ewpn,"MoveFlags[]")))
8059 {
8060 int32_t indx = ri->d[rINDEX]/10000;
8061 if(BC::checkBounds(indx, 0, 10, "eweapon->MoveFlags[]") != SH::_NoError)
8062 ret = 0; //false
8063 else
8064 {
8065 //All bits, in order, of a single byte; just use bitwise
8066 ret = (((weapon*)(s))->moveflags & (1<<indx)) ? 10000 : 0;
8067 }
8068 }
8069 break;
8070 }
8071 case EWPNFLAGS:
8072 {
8073 if(0!=(s=checkEWpn(ri->ewpn,"Flags[]")))
8074 {
8075 int32_t indx = ri->d[rINDEX]/10000;
8076 if(BC::checkBounds(indx, 0, WFLAG_MAX, "eweapon->Flags[]") != SH::_NoError)
8077 ret = 0; //false
8078 else
8079 {
8080 //All bits, in order, of a single byte; just use bitwise
8081 ret = (((weapon*)(s))->misc_wflags & (1<<indx)) ? 10000 : 0;
8082 }
8083 }
8084 break;
8085 }
8086
8087 case EWPNGLOWRAD:
8088 if(0!=(s=checkEWpn(ri->ewpn,"LightRadius")))
8089 {
8090 ret = ((weapon*)(s))->glowRad * 10000;
8091 }
8092 break;
8093
8094 case EWPNGLOWSHP:
8095 if(0!=(s=checkEWpn(ri->ewpn,"LightShape")))
8096 {
8097 ret = ((weapon*)(s))->glowShape * 10000;
8098 }
8099 break;
8100
8101 case EWPNUNBL:
8102 if(0!=(s=checkEWpn(ri->ewpn,"Unblockable")))
8103 {
8104 ret = ((weapon*)(s))->unblockable * 10000;
8105 }
8106 break;
8107
8108 case EWPNSHADOWSPR:
8109 if(0!=(s=checkEWpn(ri->ewpn,"ShadowSprite")))
8110 {
8111 ret = ((weapon*)(s))->spr_shadow * 10000;
8112 }
8113 break;
8114 case EWSWHOOKED:
8115 if(0!=(s=checkEWpn(ri->ewpn,"SwitchHooked")))
8116 {
8117 ret = s->switch_hooked ? 10000 : 0;
8118 }
8119 break;
8120 case EWPNTIMEOUT:
8121 if(0!=(s=checkEWpn(ri->ewpn,"Timeout")))
8122 {
8123 ret = ((weapon*)(s))->weap_timeout * 10000;
8124 }
8125 break;
8126 case EWPNDEATHITEM:
8127 if(0!=(s=checkEWpn(ri->ewpn,"DeathItem")))
8128 {
8129 ret = ((weapon*)(s))->death_spawnitem * 10000;
8130 }
8131 break;
8132 case EWPNDEATHDROPSET:
8133 if(0!=(s=checkEWpn(ri->ewpn,"DeathDropset")))
8134 {
8135 ret = ((weapon*)(s))->death_spawndropset * 10000;
8136 }
8137 break;
8138 case EWPNDEATHIPICKUP:
8139 if(0!=(s=checkEWpn(ri->ewpn,"DeathItemPFlags")))
8140 {
8141 ret = ((weapon*)(s))->death_item_pflags * 10000;
8142 }
8143 break;
8144 case EWPNDEATHSPRITE:
8145 if(0!=(s=checkEWpn(ri->ewpn,"DeathSprite")))
8146 {
8147 ret = ((weapon*)(s))->death_sprite * 10000;
8148 }
8149 break;
8150 case EWPNDEATHSFX:
8151 if(0!=(s=checkEWpn(ri->ewpn,"DeathSFX")))
8152 {
8153 ret = ((weapon*)(s))->death_sfx * 10000;
8154 }
8155 break;
8156 case EWPNLIFTLEVEL:
8157 if(0!=(s=checkEWpn(ri->ewpn,"LiftLevel")))
8158 {
8159 ret = ((weapon*)(s))->lift_level * 10000;
8160 }
8161 break;
8162 case EWPNLIFTTIME:
8163 if(0!=(s=checkEWpn(ri->ewpn,"LiftTime")))
8164 {
8165 ret = ((weapon*)(s))->lift_time * 10000;
8166 }
8167 break;
8168 case EWPNLIFTHEIGHT:
8169 if(0!=(s=checkEWpn(ri->ewpn,"LiftHeight")))
8170 {
8171 ret = ((weapon*)(s))->lift_height.getZLong();
8172 }
8173 break;
8174
8175 /*
8176 case LWEAPONSCRIPTUID:
8177 if(0!=(s=checkLWpn(ri->lwpn,"ScriptUID")))
8178 ret=(((weapon*)(s))->getScriptUID()); //literal, not *10000
8179
8180 break;
8181 case EWEAPONSCRIPTUID:
8182 if(0!=(s=checkLWpn(ri->ewpn,"ScriptUID")))
8183 ret=(((weapon*)(s))->getScriptUID()); //literal, not *10000
8184
8185 break;
8186 */
8187
8188 ///----------------------------------------------------------------------------------------------------//
8189 //Game Info
8190
8191
8192 case GAMEPLAYFIELDOFS:
8193 ret = playing_field_offset*10000;
8194 break;
8195
8196 case GETPIXEL:
8197 ret=FFCore.do_getpixel();
8198 break;
8199
8200
8201 case ZELDAVERSION:
8202 ret = ZC_VERSION; //Do *not* multiply by 10,000!
8203 break;
8204 case ZELDABUILD:
8205 ret = (int32_t)VERSION_BUILD*10000;
8206 break;
8207
8208 case ZSCRIPTVERSION:
8209 {
8210 ret = (FFCore.quest_format[vLastCompile]) * 10000;
8211 break;
8212 }
8213
8214 case ZELDABETATYPE:
8215 {
8216 ret = int32_t(ALPHA_STATE*10000);
8217 break;
8218 }
8219 case ZELDABETA:
8220 {
8221 ret = int32_t(ALPHA_VER*10000);
8222 if(ZC_IS_NIGHTLY) //Nightly 111/112 should return '111.5' not '112'
8223 ret -= 5000;
8224 break;
8225 }
8226 case GAMEDEATHS:
8227 ret=game->get_deaths()*10000;
8228 break;
8229
8230 case GAMECHEAT:
8231 ret=cheat*10000;
8232 break;
8233
8234 case GAMEMAXCHEAT:
8235 ret=maxcheat*10000;
8236 break;
8237
8238 case GAMETIME:
8239 2103 ret=game->get_time();
8240 2103 break;// Can't multiply by 10000 or the maximum result is too big
8241 case ACTIVESSSPEED:
8242 ret=Hero.subscr_speed*10000;
8243 break;// Can't multiply by 10000 or the maximum result is too big
8244
8245 case GAMETIMEVALID:
8246 2103 ret=game->get_timevalid()?10000:0;
8247 2103 break;
8248
8249 case GAMEHASPLAYED:
8250 ret=game->get_hasplayed()?10000:0;
8251 break;
8252
8253 case TYPINGMODE:
8254 ret=FFCore.kb_typing_mode?10000:0;
8255 break;
8256
8257 case SKIPCREDITS:
8258 ret=FFCore.skip_ending_credits?10000:0;
8259 break;
8260
8261 case SKIPF6:
8262 ret=get_qr(qr_NOCONTINUE)?10000:0;
8263 break;
8264
8265 case GAMESTANDALONE:
8266 17 ret=standalone_mode?10000:0;
8267 17 break;
8268
8269 case GAMEGUYCOUNT:
8270 {
8271 26 int32_t mi = (currmap*MAPSCRSNORMAL)+(ri->d[rINDEX]/10000);
8272 26 ret=game->guys[mi]*10000;
8273 }
8274 26 break;
8275
8276 case GAMECONTSCR:
8277 678 ret=game->get_continue_scrn()*10000;
8278 678 break;
8279
8280 case GAMECONTDMAP:
8281 972 ret=game->get_continue_dmap()*10000;
8282 972 break;
8283
8284 case GAMEENTRSCR:
8285 14 ret=lastentrance*10000;
8286 14 break;
8287
8288 case GAMEENTRDMAP:
8289 471 ret=lastentrance_dmap*10000;
8290 471 break;
8291
8292 case GAMECOUNTERD:
8293 4033084 ret=game->get_counter((ri->d[rINDEX])/10000)*10000;
8294 4033084 break;
8295
8296 case GAMEMCOUNTERD:
8297 1608203 ret=game->get_maxcounter((ri->d[rINDEX])/10000)*10000;
8298 1608203 break;
8299
8300 case GAMEDCOUNTERD:
8301 15 ret=game->get_dcounter((ri->d[rINDEX])/10000)*10000;
8302 15 break;
8303
8304 case GAMEGENERICD:
8305 856 ret=game->get_generic((ri->d[rINDEX])/10000)*10000;
8306 856 break;
8307
8308 case GAMEMISC:
8309 {
8310 int32_t indx = ri->d[rINDEX]/10000;
8311 if ( indx < 0 || indx > 31 )
8312 {
8313 ret = -10000;
8314 Z_scripterrlog("Invalud index used to access Game->Misc: %d\n", indx);
8315 }
8316 else
8317 {
8318 ret = QMisc.questmisc[indx]*((get_qr(qr_OLDQUESTMISC)) ? 10000 : 1);
8319 }
8320 break;
8321 }
8322
8323 case GAMEITEMSD:
8324 ret=(game->item[(ri->d[rINDEX])/10000] ? 10000 : 0);
8325 break;
8326 case DISABLEDITEM:
8327 ret = (game->items_off[(ri->d[rINDEX])/10000] ? 10000 : 0);
8328 break;
8329 case GAMESUSPEND:
8330 {
8331 700 int32_t inx = (ri->d[rINDEX])/10000;
8332
1/2
✓ Branch 0 taken 700 times.
✗ Branch 1 not taken.
700 if ( (unsigned) inx > (susptLAST-1) )
8333 {
8334 Z_scripterrlog("Invalid array index [%d] passed to Gme->Suspend[]\n");
8335 }
8336 700 ret = (( FFCore.system_suspend[inx] ) ? 10000 : 0);
8337 700 break;
8338 }
8339 case GAMELITEMSD:
8340 2369090 ret=game->lvlitems[(ri->d[rINDEX])/10000]*10000;
8341 2369090 break;
8342 case GAMELSWITCH:
8343 {
8344 int32_t ind = (ri->d[rINDEX])/10000;
8345 if(unsigned(ind) >= MAXLEVELS)
8346 ret = 0;
8347 else ret=game->lvlswitches[ind];
8348 break;
8349 }
8350 case GAMEGSWITCH:
8351 {
8352 int32_t ind = (ri->d[rINDEX])/10000;
8353 if(unsigned(ind) >= NUM_GSWITCHES)
8354 ret = 0;
8355 else ret=game->gswitch_timers[ind]*10000;
8356 break;
8357 }
8358 case GAMEBOTTLEST:
8359 ret=game->get_bottle_slot((ri->d[rINDEX])/10000)*10000;
8360 break;
8361
8362 case GAMELKEYSD:
8363 561833 ret=game->lvlkeys[(ri->d[rINDEX])/10000]*10000;
8364 561833 break;
8365
8366 case TANGOARR:
8367 {
8368 int32_t inx = (ri->d[rINDEX])/10000;
8369 if ( ((unsigned)inx) > 255 )
8370 {
8371 Z_scripterrlog("Invalid index %d supplied to Game->Tango[].\n", inx);
8372 ret = -10000;
8373 break;
8374 }
8375 else
8376 {
8377 ret=FFCore.TangoArray[inx]*10000;
8378 break;
8379 }
8380 }
8381 case GHOSTARR:
8382 {
8383 int32_t inx = (ri->d[rINDEX])/10000;
8384 if ( ((unsigned)inx) > 255 )
8385 {
8386 Z_scripterrlog("Invalid index %d supplied to Game->Ghost[].\n", inx);
8387 ret = -10000;
8388 break;
8389 }
8390 else
8391 {
8392 ret=FFCore.GhostArray[inx]*10000;
8393 break;
8394 }
8395 }
8396 case STDARR:
8397 {
8398 int32_t inx = (ri->d[rINDEX])/10000;
8399 if ( ((unsigned)inx) > 255 )
8400 {
8401 Z_scripterrlog("Invalid index %d supplied to Game->STD[].\n", inx);
8402 ret = -10000;
8403 break;
8404 }
8405 else
8406 {
8407 ret=FFCore.StdArray[inx]*10000;
8408 break;
8409 }
8410 }
8411
8412 case GAMEMISCSPR:
8413 {
8414 int32_t inx = (ri->d[rINDEX])/10000;
8415 if ( ((unsigned)inx) > sprMAX )
8416 {
8417 Z_scripterrlog("Invalid index %d supplied to Game->MiscSprites[].\n", inx);
8418 ret = -10000;
8419 }
8420 else
8421 {
8422 ret = QMisc.sprites[inx] * 10000;
8423 }
8424 break;
8425 }
8426 case GAMEMISCSFX:
8427 {
8428 int32_t inx = (ri->d[rINDEX])/10000;
8429 if ( ((unsigned)inx) > sfxMAX )
8430 {
8431 Z_scripterrlog("Invalid index %d supplied to Game->MiscSFX[].\n", inx);
8432 ret = -10000;
8433 }
8434 else
8435 {
8436 ret = QMisc.miscsfx[inx] * 10000;
8437 }
8438 break;
8439 }
8440 case GAMEOVERRIDEITEMS:
8441 {
8442 int32_t ind = (ri->d[rINDEX])/10000;
8443 if(unsigned(ind) >= itype_max)
8444 {
8445 Z_scripterrlog("Invalid index %d supplied to Game->OverrideItems[].\n", ind);
8446 ret = -20000;
8447 }
8448 else ret = game->OverrideItems[ind] * 10000;
8449 break;
8450 }
8451 case GAMEEVENTDATA:
8452 {
8453 int32_t inx = (ri->d[rINDEX])/10000;
8454 ret = 0;
8455 if ( ((unsigned)inx) < FFCore.eventData.size() )
8456 {
8457 ret = FFCore.eventData[inx];
8458 }
8459 break;
8460 }
8461 case GAMEMOUSECURSOR:
8462 {
8463 ret = game_mouse_index*10000;
8464 break;
8465 }
8466 case GAMETRIGGROUPS:
8467 {
8468 int32_t ind = (ri->d[rINDEX])/10000;
8469 if(unsigned(ind)>255)
8470 Z_scripterrlog("Invalid index %d supplied to Game->TrigGroups[]\n",ind);
8471 ret = get_trig_group(ind)*10000;
8472 break;
8473 }
8474
8475 case GAMEGRAVITY:
8476 {
8477 int32_t indx = ri->d[rINDEX]/10000;
8478 if ( ((unsigned)indx) > 2 )
8479 //if(indx < 0 || indx > 2)
8480 {
8481 ret = -10000;
8482 Z_scripterrlog("Invalid index used to access Game->Gravity[]: %d\n", indx);
8483 }
8484 else
8485 {
8486 switch(indx)
8487 {
8488 case 0: //Gravity Strength
8489 ret = zinit.gravity2;
8490 break;
8491 case 1: //Terminal Velocity
8492 ret = zinit.terminalv * 100;
8493 break;
8494 case 2: //Sprite Layer Threshold
8495 ret = zinit.jump_hero_layer_threshold * 10000;
8496 break;
8497 }
8498 }
8499 break;
8500 }
8501
8502 case GAMESCROLLING:
8503 {
8504 191517 int32_t indx = ri->d[rINDEX]/10000;
8505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 191517 times.
191517 if ( ((unsigned)indx) >= SZ_SCROLLDATA )
8506 //if(indx < 0 || indx >= SZ_SCROLLDATA)
8507 {
8508 Z_scripterrlog("Invalid index used to access Game->Scrolling[]: %d\n", indx);
8509 }
8510 else
8511 {
8512 191517 ret = FFCore.ScrollingData[indx] * 10000L;
8513 }
8514 191517 break;
8515 }
8516
8517
8518 case SCREENSTATED:
8519 {
8520 1218351 int32_t mi = get_mi(MAPSCR_TEMP0);
8521
1/2
✓ Branch 0 taken 1218351 times.
✗ Branch 1 not taken.
1218351 if(mi<0) {ret = 0;break;}
8522 1218351 ret=((game->maps[mi]>>((ri->d[rINDEX]/10000)))&1)?10000:0;
8523 }
8524 1218351 break;
8525 case SCREENEXSTATED:
8526 {
8527 int32_t mi = get_mi(MAPSCR_TEMP0);
8528 if(mi<0) {ret = 0;break;}
8529 ret=((game->xstates[mi]>>((ri->d[rINDEX]/10000)))&1)?10000:0;
8530 }
8531 break;
8532 case SCREENLENSSHOWS:
8533 {
8534 int ind = ri->d[rINDEX]/10000;
8535 if(ind < 0 || ind > 6)
8536 Z_scripterrlog("Bad index Screen->LensShows[%d]\n",ind);
8537 else ret = (tmpscr->lens_show & (1<<ind)) ? 10000 : 0;
8538 break;
8539 }
8540 case SCREENLENSHIDES:
8541 {
8542 int ind = ri->d[rINDEX]/10000;
8543 if(ind < 0 || ind > 6)
8544 Z_scripterrlog("Bad index Screen->LensHides[%d]\n",ind);
8545 else ret = (tmpscr->lens_hide & (1<<ind)) ? 10000 : 0;
8546 break;
8547 }
8548 case SCREENSCRDATASIZE:
8549 {
8550 auto mi = get_total_mi();
8551 if(mi < 0) break;
8552 ret = 10000*game->scriptDataSize(mi);
8553 break;
8554 }
8555 case SCREENSCRDATA:
8556 {
8557 auto mi = get_total_mi();
8558 if(mi < 0) break;
8559 size_t indx = ri->d[rINDEX]/10000;
8560 if(indx >= game->scriptDataSize(mi))
8561 {
8562 Z_scripterrlog("Invalid index passed to Screen->Data[]: %d\n", indx);
8563 break;
8564 }
8565 ret = game->screen_data[mi][indx];
8566 break;
8567 }
8568
8569 case DISTANCE:
8570 {
8571 225833 double x1 = double(ri->d[rSFTEMP] / 10000.0);
8572 225833 double y1 = double(ri->d[rINDEX] / 10000.0);
8573 225833 double x2 = double(ri->d[rINDEX2] / 10000.0);
8574 225833 double y2 = double(ri->d[rEXP1] / 10000.0);
8575
8576
8577
8578 225833 int32_t result = FFCore.Distance(x1, y1, x2, y2);
8579 225833 ret = (result);
8580
8581 225833 break;
8582 }
8583 case LONGDISTANCE:
8584 {
8585 double x1 = double(ri->d[rSFTEMP]);
8586 double y1 = double(ri->d[rINDEX]);
8587 double x2 = double(ri->d[rINDEX2]);
8588 double y2 = double(ri->d[rEXP1]);
8589
8590
8591
8592 int32_t result = FFCore.LongDistance(x1, y1, x2, y2);
8593 ret = (result);
8594
8595 break;
8596 }
8597
8598 case DISTANCESCALE:
8599 {
8600 double x1 = (double)(ri->d[rSFTEMP] / 10000.0);
8601 zprint2("x1 is: %f\n", x1);
8602 double y1 = (double)(ri->d[rINDEX] / 10000.0);
8603 zprint2("y1 is: %f\n", y1);
8604 double x2 = (double)(ri->d[rINDEX2] / 10000.0);
8605 zprint2("x2 is: %f\n", x2);
8606 double y2 = (double)(ri->d[rEXP1] / 10000.0);
8607 zprint2("y2 is: %f\n", y2);
8608
8609 int32_t scale = (ri->d[rWHAT_NO_7]/10000);
8610 zprint2("Scale is: %d\n", scale);
8611
8612 if ( !scale ) scale = 10000;
8613 int32_t result = FFCore.Distance(x1, y1, x2, y2, scale);
8614 ret = (result);
8615
8616 break;
8617 }
8618 case LONGDISTANCESCALE:
8619 {
8620 double x1 = (double)(ri->d[rSFTEMP]);
8621 zprint2("x1 is: %f\n", x1);
8622 double y1 = (double)(ri->d[rINDEX]);
8623 zprint2("y1 is: %f\n", y1);
8624 double x2 = (double)(ri->d[rINDEX2]);
8625 zprint2("x2 is: %f\n", x2);
8626 double y2 = (double)(ri->d[rEXP1]);
8627 zprint2("y2 is: %f\n", y2);
8628
8629 int32_t scale = (ri->d[rWHAT_NO_7]);
8630 zprint2("Scale is: %d\n", scale);
8631
8632 if ( !scale ) scale = 1;
8633 int32_t result = FFCore.LongDistance(x1, y1, x2, y2, scale);
8634 ret = (result);
8635
8636 break;
8637 }
8638
8639 case SCREENSTATEDD:
8640 {
8641 // Gah! >:( Screen state is stored in game->maps, which uses 128 screens per map,
8642 // but the compiler multiplies the map number by 136, so it has to be corrected here.
8643 // Yeah, the compiler could be fixed, but that wouldn't cover existing quests...
8644 18739404 int32_t mi = ri->d[rINDEX] / 10000;
8645 18739404 mi -= 8*((ri->d[rINDEX] / 10000) / MAPSCRS);
8646
8647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18739404 times.
18739404 if(BC::checkMapID(mi>>7, "Game->GetScreenState") == SH::_NoError)
8648 18739404 ret=(game->maps[mi] >> (ri->d[rINDEX2] / 10000) & 1) ? 10000 : 0;
8649 else
8650 ret=0;
8651
8652 18739404 break;
8653 }
8654
8655 case GAMEGUYCOUNTD:
8656 ret=game->guys[(currmap * MAPSCRSNORMAL) + (ri->d[rINDEX] / 10000)]*10000;
8657 break;
8658
8659 case CURMAP:
8660 22596069 ret=(1+currmap)*10000;
8661 22596069 break;
8662
8663 case CURSCR:
8664 14112446 ret=currscr*10000;
8665 14112446 break;
8666
8667 case ALLOCATEBITMAPR:
8668 125 ret=FFCore.do_allocate_bitmap();
8669 125 break;
8670
8671 case GETMIDI:
8672 63717 ret=(currmidi-(ZC_MIDI_COUNT-1))*10000;
8673 63717 break;
8674
8675 case CURDSCR:
8676 {
8677 5922840 int32_t di = (get_currscr()-DMaps[get_currdmap()].xoff);
8678
2/2
✓ Branch 0 taken 3036915 times.
✓ Branch 1 taken 2885925 times.
5922840 ret=(DMaps[get_currdmap()].type==dmOVERW ? currscr : di)*10000;
8679 }
8680 5922840 break;
8681
8682 case GAMEMAXMAPS:
8683 ret = (map_count)*10000;
8684 break;
8685 case GAMENUMMESSAGES:
8686 ret = (msg_count-1) * 10000;
8687 break;
8688
8689 case CURDMAP:
8690 49235831 ret=currdmap*10000;
8691 49235831 break;
8692
8693 case CURLEVEL:
8694 14025143 ret=DMaps[get_currdmap()].level*10000;
8695 14025143 break;
8696
8697 case GAMECLICKFREEZE:
8698 ret=disableClickToFreeze?0:10000;
8699 break;
8700
8701
8702 case NOACTIVESUBSC:
8703 ret=Hero.stopSubscreenFalling()?10000:0;
8704 break;///----------------------------------------------------------------------------------------------------//
8705 //BottleTypes
8706 case BOTTLECOUNTER:
8707 {
8708 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Counter[]"))
8709 {
8710 int32_t indx = ri->d[rINDEX]/10000;
8711 if(unsigned(indx) > 2)
8712 {
8713 Z_scripterrlog("Invalid index %d supplied to bottledata->Counter[].\n", indx);
8714 ret = -10000L;
8715 break;
8716 }
8717 ret = 10000L * ptr->counter[indx];
8718 }
8719 else ret = -10000L;
8720 }
8721 break;
8722
8723 case BOTTLEAMOUNT:
8724 {
8725 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Amount[]"))
8726 {
8727 int32_t indx = ri->d[rINDEX]/10000;
8728 if(unsigned(indx) > 2)
8729 {
8730 Z_scripterrlog("Invalid index %d supplied to bottledata->Amount[].\n", indx);
8731 ret = -10000L;
8732 break;
8733 }
8734 ret = 10000L * ptr->amount[indx];
8735 }
8736 else ret = -10000L;
8737 }
8738 break;
8739
8740 case BOTTLEPERCENT:
8741 {
8742 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "IsPercent[]"))
8743 {
8744 int32_t indx = ri->d[rINDEX]/10000;
8745 if(unsigned(indx) > 2)
8746 {
8747 Z_scripterrlog("Invalid index %d supplied to bottledata->IsPercent[].\n", indx);
8748 ret = -10000L;
8749 break;
8750 }
8751 ret = (ptr->flags & (1<<indx)) ? 10000L : 0;
8752 }
8753 else ret = -10000L;
8754 }
8755 break;
8756
8757 case BOTTLEFLAGS:
8758 {
8759 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Flags[]"))
8760 {
8761 int32_t indx = ri->d[rINDEX]/10000;
8762 if(unsigned(indx) > 3)
8763 {
8764 Z_scripterrlog("Invalid index %d supplied to bottledata->Flags[].\n", indx);
8765 ret = -10000L;
8766 break;
8767 }
8768 int32_t flag = 0;
8769 switch(indx)
8770 {
8771 case 0: flag = BTFLAG_AUTOONDEATH; break;
8772 case 1: flag = BTFLAG_ALLOWIFFULL; break;
8773 case 2: flag = BTFLAG_CURESWJINX; break;
8774 case 3: flag = BTFLAG_CUREITJINX; break;
8775 }
8776 ret = (ptr->flags & flag) ? 10000L : 0;
8777 }
8778 else ret = -10000L;
8779 }
8780 break;
8781
8782 case BOTTLENEXT:
8783 {
8784 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "NextType"))
8785 {
8786 ret = 10000L * ptr->next_type;
8787 }
8788 else ret = -10000L;
8789 }
8790 break;
8791 ///----------------------------------------------------------------------------------------------------//
8792 //BottleShops
8793 case BSHOPFILL:
8794 {
8795 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Fill[]"))
8796 {
8797 int32_t indx = ri->d[rINDEX]/10000;
8798 if(unsigned(indx) > 2)
8799 {
8800 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Fill[].\n", indx);
8801 ret = -10000L;
8802 break;
8803 }
8804 ret = 10000L * ptr->fill[indx];
8805 }
8806 else ret = -10000L;
8807 }
8808 break;
8809
8810 case BSHOPCOMBO:
8811 {
8812 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Combo[]"))
8813 {
8814 int32_t indx = ri->d[rINDEX]/10000;
8815 if(unsigned(indx) > 2)
8816 {
8817 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Combo[].\n", indx);
8818 ret = -10000L;
8819 break;
8820 }
8821 ret = 10000L * ptr->comb[indx];
8822 }
8823 else ret = -10000L;
8824 }
8825 break;
8826
8827 case BSHOPCSET:
8828 {
8829 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "CSet[]"))
8830 {
8831 int32_t indx = ri->d[rINDEX]/10000;
8832 if(unsigned(indx) > 2)
8833 {
8834 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->CSet[].\n", indx);
8835 ret = -10000L;
8836 break;
8837 }
8838 ret = 10000L * ptr->cset[indx];
8839 }
8840 else ret = -10000L;
8841 }
8842 break;
8843
8844 case BSHOPPRICE:
8845 {
8846 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Price[]"))
8847 {
8848 int32_t indx = ri->d[rINDEX]/10000;
8849 if(unsigned(indx) > 2)
8850 {
8851 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Price[].\n", indx);
8852 ret = -10000L;
8853 break;
8854 }
8855 ret = 10000L * ptr->price[indx];
8856 }
8857 else ret = -10000L;
8858 }
8859 break;
8860
8861 case BSHOPSTR:
8862 {
8863 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "InfoString[]"))
8864 {
8865 int32_t indx = ri->d[rINDEX]/10000;
8866 if(unsigned(indx) > 2)
8867 {
8868 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->InfoString[].\n", indx);
8869 ret = -10000L;
8870 break;
8871 }
8872 ret = 10000L * ptr->str[indx];
8873 }
8874 else ret = -10000L;
8875 }
8876 break;
8877
8878 ///----------------------------------------------------------------------------------------------------//
8879 //DMap Information
8880
8881 #define GET_DMAP_VAR(member, str) \
8882 { \
8883 int32_t ID = ri->d[rINDEX] / 10000; \
8884 if(BC::checkDMapID(ID, str) != SH::_NoError) \
8885 ret = -10000; \
8886 else \
8887 ret = DMaps[ID].member * 10000; \
8888 }
8889
8890 case DMAPFLAGSD:
8891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1764243 times.
1764243 GET_DMAP_VAR(flags, "Game->DMapFlags") break;
8892
8893 case DMAPLEVELD:
8894
1/2
✓ Branch 0 taken 1019 times.
✗ Branch 1 not taken.
1019 GET_DMAP_VAR(level, "Game->DMapLevel") break;
8895
8896 case DMAPCOMPASSD:
8897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255560 times.
255560 GET_DMAP_VAR(compass, "Game->DMapCompass") break;
8898
8899 case DMAPCONTINUED:
8900 GET_DMAP_VAR(cont, "Game->DMapContinue") break;
8901
8902 case DMAPLEVELPAL:
8903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 741668 times.
741668 GET_DMAP_VAR(color, "Game->DMapPalette") break;
8904
8905 case DMAPOFFSET:
8906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96115 times.
96115 GET_DMAP_VAR(xoff, "Game->DMapOffset") break;
8907
8908 case DMAPMAP:
8909 {
8910 9482 int32_t ID = ri->d[rINDEX] / 10000;
8911
8912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9482 times.
9482 if(BC::checkDMapID(ID, "Game->DMapMap") != SH::_NoError)
8913 ret = -10000;
8914 else
8915 9482 ret = (DMaps[ID].map+1) * 10000;
8916
8917 9482 break;
8918 }
8919
8920 case DMAPMIDID:
8921 {
8922 37 int32_t ID = ri->d[rINDEX] / 10000;
8923
8924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(BC::checkDMapID(ID, "Game->DMapMIDI") == SH::_NoError)
8925 {
8926 // Based on play_DmapMusic
8927
2/5
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
37 switch(DMaps[ID].midi)
8928 {
8929 case 2:
8930 ret = -60000;
8931 break; // Dungeon
8932
8933 case 3:
8934 ret = -30000;
8935 break; // Level 9
8936
8937 case 1:
8938 ret = -20000;
8939 break; // Overworld
8940
8941 case 0:
8942 4 ret = 0;
8943 4 break; // None
8944
8945 default:
8946 33 ret = (DMaps[ID].midi - 3) * 10000;
8947 33 }
8948 37 }
8949 else
8950 ret = -10000; // Which is valid, but whatever.
8951
8952 37 break;
8953 }
8954
8955 ///----------------------------------------------------------------------------------------------------//
8956 //Screen->ComboX
8957 #define GET_COMBO_VAR(member, str) \
8958 { \
8959 int32_t pos = ri->d[rINDEX] / 10000; \
8960 if(BC::checkComboPos(pos, str) != SH::_NoError) \
8961 { \
8962 ret = -10000; \
8963 } \
8964 else \
8965 ret = tmpscr->member[pos]*10000; \
8966 }
8967
8968 case COMBODD:
8969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27341446 times.
27341446 GET_COMBO_VAR(data, "Screen->ComboD[]") break;
8970
8971 case COMBOCD:
8972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2709583 times.
2709583 GET_COMBO_VAR(cset, "Screen->ComboC[]") break;
8973
8974 case COMBOFD:
8975
1/2
✓ Branch 0 taken 3906326 times.
✗ Branch 1 not taken.
3906326 GET_COMBO_VAR(sflag, "Screen->ComboF[]") break;
8976
8977 #define GET_COMBO_VAR_BUF(member, str) \
8978 { \
8979 int32_t pos = ri->d[rINDEX] / 10000; \
8980 if(BC::checkComboPos(pos, str) != SH::_NoError) \
8981 { \
8982 ret = -10000; \
8983 } \
8984 else \
8985 ret = combobuf[tmpscr->data[pos]].member * 10000; \
8986 }
8987
8988 case COMBOTD:
8989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26494416 times.
26494416 GET_COMBO_VAR_BUF(type, "Screen->ComboT[]") break;
8990
8991 case COMBOID:
8992
1/2
✓ Branch 0 taken 2975118 times.
✗ Branch 1 not taken.
2975118 GET_COMBO_VAR_BUF(flag, "Screen->ComboI[]") break;
8993
8994 case COMBOSD:
8995 {
8996 96784 int32_t pos = ri->d[rINDEX] / 10000;
8997
8998
2/2
✓ Branch 0 taken 1584 times.
✓ Branch 1 taken 95200 times.
96784 if(BC::checkComboPos(pos, "Screen->ComboS[]") != SH::_NoError)
8999 1584 ret = -10000;
9000 else
9001 95200 ret = (combobuf[tmpscr->data[pos]].walk & 0xF) * 10000;
9002 }
9003 96784 break;
9004
9005 case COMBOED:
9006 {
9007 int32_t pos = ri->d[rINDEX] / 10000;
9008
9009 if(BC::checkComboPos(pos, "Screen->ComboE[]") != SH::_NoError)
9010 ret = -10000;
9011 else
9012 ret = ((combobuf[tmpscr->data[pos]].walk & 0xF0)>>4) * 10000;
9013 }
9014 break;
9015
9016 ///----------------------------------------------------------------------------------------------------//
9017 //Game->GetComboX
9018
9019 case COMBODDM:
9020 {
9021 13758809 int32_t pos = (ri->d[rINDEX])/10000;
9022 13758809 int32_t sc = (ri->d[rEXP1]/10000);
9023 13758809 int32_t m = (ri->d[rINDEX2]/10000)-1;
9024
2/2
✓ Branch 0 taken 11885286 times.
✓ Branch 1 taken 1873523 times.
13758809 int32_t scr = zc_max(m*MAPSCRS+sc,0);
9025 13758809 int32_t layr = whichlayer(scr);
9026
9027
2/4
✓ Branch 0 taken 13758809 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13758809 times.
13758809 if(pos < 0 || pos >= 176)
9028 {
9029 Z_scripterrlog("Invalid combo position (%d) passed to GetComboData", pos);
9030 ret = -10000;
9031 }
9032
1/2
✓ Branch 0 taken 13758809 times.
✗ Branch 1 not taken.
13758809 else if(scr < 0)
9033 {
9034 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboData", scr);
9035 ret = -10000;
9036 }
9037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13758809 times.
13758809 else if(sc >= MAPSCRS)
9038 {
9039 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboData", sc);
9040 ret = -10000;
9041 }
9042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13758809 times.
13758809 else if(m >= map_count)
9043 {
9044 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboData", m);
9045 ret = -10000;
9046 }
9047
2/2
✓ Branch 0 taken 11885286 times.
✓ Branch 1 taken 1873523 times.
13758809 else if(m < 0) ret = 0; //No layer present
9048
9049 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
9050 else
9051 {
9052
2/2
✓ Branch 0 taken 109146 times.
✓ Branch 1 taken 11776140 times.
11885286 if(scr==(currmap*MAPSCRS+currscr))
9053 109146 ret=tmpscr->data[pos]*10000;
9054
2/2
✓ Branch 0 taken 5826733 times.
✓ Branch 1 taken 5949407 times.
11776140 else if(layr>-1)
9055 5826733 ret=tmpscr2[layr].data[pos]*10000;
9056 5949407 else ret=TheMaps[scr].data[pos]*10000;
9057 }
9058
9059 }
9060 13758809 break;
9061
9062 case COMBOCDM:
9063 {
9064 2272124 int32_t pos = (ri->d[rINDEX])/10000;
9065 2272124 int32_t sc = (ri->d[rEXP1]/10000);
9066 2272124 int32_t m = (ri->d[rINDEX2]/10000)-1;
9067
1/2
✓ Branch 0 taken 2272124 times.
✗ Branch 1 not taken.
2272124 int32_t scr = zc_max(m*MAPSCRS+sc,0);
9068 2272124 int32_t layr = whichlayer(scr);
9069
9070
2/4
✓ Branch 0 taken 2272124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2272124 times.
2272124 if(pos < 0 || pos >= 176)
9071 {
9072 Z_scripterrlog("Invalid combo position (%d) passed to GetComboCSet", pos);
9073 ret = -10000;
9074 }
9075
1/2
✓ Branch 0 taken 2272124 times.
✗ Branch 1 not taken.
2272124 else if(scr < 0)
9076 {
9077 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboCSet", scr);
9078 ret = -10000;
9079 }
9080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2272124 times.
2272124 else if(sc >= MAPSCRS)
9081 {
9082 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboCSet", sc);
9083 ret = -10000;
9084 }
9085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2272124 times.
2272124 else if(m >= map_count)
9086 {
9087 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboCSet", m);
9088 ret = -10000;
9089 }
9090
1/2
✓ Branch 0 taken 2272124 times.
✗ Branch 1 not taken.
2272124 else if(m < 0) ret = 0; //No layer present
9091
9092 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
9093 else
9094 {
9095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2272124 times.
2272124 if(scr==(currmap*MAPSCRS+currscr))
9096 ret=tmpscr->cset[pos]*10000;
9097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2272124 times.
2272124 else if(layr>-1)
9098 ret=tmpscr2[layr].cset[pos]*10000;
9099 2272124 else ret=TheMaps[scr].cset[pos]*10000;
9100 }
9101
9102 }
9103 2272124 break;
9104
9105 case COMBOFDM:
9106 {
9107 5866709 int32_t pos = (ri->d[rINDEX])/10000;
9108 5866709 int32_t sc = (ri->d[rEXP1]/10000);
9109 5866709 int32_t m = (ri->d[rINDEX2]/10000)-1;
9110
1/2
✓ Branch 0 taken 5866709 times.
✗ Branch 1 not taken.
5866709 int32_t scr = zc_max(m*MAPSCRS+sc,0);
9111 5866709 int32_t layr = whichlayer(scr);
9112
9113
3/4
✓ Branch 0 taken 5866709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4000 times.
✓ Branch 3 taken 5862709 times.
5866709 if(pos < 0 || pos >= 176)
9114 {
9115 4000 Z_scripterrlog("Invalid combo position (%d) passed to GetComboFlag", pos);
9116 4000 ret = -10000;
9117 4000 }
9118
1/2
✓ Branch 0 taken 5862709 times.
✗ Branch 1 not taken.
5862709 else if(scr < 0)
9119 {
9120 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboFlag", scr);
9121 ret = -10000;
9122 }
9123
2/2
✓ Branch 0 taken 4212 times.
✓ Branch 1 taken 5858497 times.
5862709 else if(sc >= MAPSCRS)
9124 {
9125 4212 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboFlag", sc);
9126 4212 ret = -10000;
9127 4212 }
9128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5858497 times.
5858497 else if(m >= map_count)
9129 {
9130 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboFlag", m);
9131 ret = -10000;
9132 }
9133
1/2
✓ Branch 0 taken 5858497 times.
✗ Branch 1 not taken.
5858497 else if(m < 0) ret = 0; //No layer present
9134 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
9135 else
9136 {
9137
2/2
✓ Branch 0 taken 317735 times.
✓ Branch 1 taken 5540762 times.
5858497 if(scr==(currmap*MAPSCRS+currscr))
9138 317735 ret=tmpscr->sflag[pos]*10000;
9139
2/2
✓ Branch 0 taken 4629060 times.
✓ Branch 1 taken 911702 times.
5540762 else if(layr>-1)
9140 4629060 ret=tmpscr2[layr].sflag[pos]*10000;
9141 911702 else ret=TheMaps[scr].sflag[pos]*10000;
9142 }
9143
9144 }
9145 5866709 break;
9146
9147 case COMBOTDM:
9148 {
9149 449777 int32_t pos = (ri->d[rINDEX])/10000;
9150 449777 int32_t sc = (ri->d[rEXP1]/10000);
9151 449777 int32_t m = (ri->d[rINDEX2]/10000)-1;
9152
1/2
✓ Branch 0 taken 449777 times.
✗ Branch 1 not taken.
449777 int32_t scr = zc_max(m*MAPSCRS+sc,0);
9153 449777 int32_t layr = whichlayer(scr);
9154
9155
2/4
✓ Branch 0 taken 449777 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 449777 times.
449777 if(pos < 0 || pos >= 176)
9156 {
9157 Z_scripterrlog("Invalid combo position (%d) passed to GetComboType", pos);
9158 ret = -10000;
9159 }
9160
1/2
✓ Branch 0 taken 449777 times.
✗ Branch 1 not taken.
449777 else if(scr < 0)
9161 {
9162 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboType", scr);
9163 ret = -10000;
9164 }
9165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 449777 times.
449777 else if(sc >= MAPSCRS)
9166 {
9167 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboType", sc);
9168 ret = -10000;
9169 }
9170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 449777 times.
449777 else if(m >= map_count)
9171 {
9172 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboType", m);
9173 ret = -10000;
9174 }
9175
1/2
✓ Branch 0 taken 449777 times.
✗ Branch 1 not taken.
449777 else if(m < 0) ret = 0; //No layer present
9176
9177 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
9178 else
9179 {
9180
2/2
✓ Branch 0 taken 106581 times.
✓ Branch 1 taken 343196 times.
449777 if(scr==(currmap*MAPSCRS+currscr))
9181 106581 ret=combobuf[tmpscr->data[pos]].type*10000;
9182
2/2
✓ Branch 0 taken 105393 times.
✓ Branch 1 taken 237803 times.
343196 else if(layr>-1)
9183 105393 ret=combobuf[tmpscr2[layr].data[pos]].type*10000;
9184 713409 else ret=combobuf[
9185 713409 TheMaps[scr].data[pos]].type*10000;
9186 }
9187 }
9188 449777 break;
9189
9190 case COMBOIDM:
9191 {
9192 421915 int32_t pos = (ri->d[rINDEX])/10000;
9193 421915 int32_t sc = (ri->d[rEXP1]/10000);
9194 421915 int32_t m = (ri->d[rINDEX2]/10000)-1;
9195
1/2
✓ Branch 0 taken 421915 times.
✗ Branch 1 not taken.
421915 int32_t scr = zc_max(m*MAPSCRS+sc,0);
9196 421915 int32_t layr = whichlayer(scr);
9197
9198
3/4
✓ Branch 0 taken 421915 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4000 times.
✓ Branch 3 taken 417915 times.
421915 if(pos < 0 || pos >= 176)
9199 {
9200 4000 Z_scripterrlog("Invalid combo position (%d) passed to GetComboInherentFlag", pos);
9201 4000 ret = -10000;
9202 4000 }
9203
1/2
✓ Branch 0 taken 417915 times.
✗ Branch 1 not taken.
417915 else if(scr < 0)
9204 {
9205 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboInherentFlag", scr);
9206 ret = -10000;
9207 }
9208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 417915 times.
417915 else if(sc >= MAPSCRS)
9209 {
9210 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboInherentFlag", sc);
9211 ret = -10000;
9212 }
9213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 417915 times.
417915 else if(m >= map_count)
9214 {
9215 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboInherentFlag", m);
9216 ret = -10000;
9217 }
9218
1/2
✓ Branch 0 taken 417915 times.
✗ Branch 1 not taken.
417915 else if(m < 0) ret = 0; //No layer present
9219
9220 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
9221 else
9222 {
9223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 417915 times.
417915 if(scr==(currmap*MAPSCRS+currscr))
9224 ret=combobuf[tmpscr->data[pos]].flag*10000;
9225
1/2
✓ Branch 0 taken 417915 times.
✗ Branch 1 not taken.
417915 else if(layr>-1)
9226 417915 ret=combobuf[tmpscr2[layr].data[pos]].flag*10000;
9227 else ret=combobuf[TheMaps[scr].data[pos]].flag*10000;
9228 }
9229 }
9230 421915 break;
9231
9232 case COMBOSDM:
9233 {
9234 6342577 int32_t pos = (ri->d[rINDEX])/10000;
9235 6342577 int32_t sc = (ri->d[rEXP1]/10000);
9236 6342577 int32_t m = (ri->d[rINDEX2]/10000)-1;
9237
2/2
✓ Branch 0 taken 6341872 times.
✓ Branch 1 taken 705 times.
6342577 int32_t scr = zc_max(m*MAPSCRS+sc,0);
9238 6342577 int32_t layr = whichlayer(scr);
9239
9240
2/4
✓ Branch 0 taken 6342577 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6342577 times.
6342577 if(pos < 0 || pos >= 176)
9241 {
9242 Z_scripterrlog("Invalid combo position (%d) passed to GetComboSolid", pos);
9243 ret = -10000;
9244 }
9245
1/2
✓ Branch 0 taken 6342577 times.
✗ Branch 1 not taken.
6342577 else if(scr < 0)
9246 {
9247 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboSolid", scr);
9248 ret = -10000;
9249 }
9250
2/2
✓ Branch 0 taken 2106 times.
✓ Branch 1 taken 6340471 times.
6342577 else if(sc >= MAPSCRS)
9251 {
9252 2106 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboSolid", sc);
9253 2106 ret = -10000;
9254 2106 }
9255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6340471 times.
6340471 else if(m >= map_count)
9256 {
9257 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboSolid", m);
9258 ret = -10000;
9259 }
9260
2/2
✓ Branch 0 taken 6339767 times.
✓ Branch 1 taken 704 times.
6340471 else if(m < 0) ret = 0; //No layer present
9261
9262 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
9263 else
9264 {
9265
2/2
✓ Branch 0 taken 581032 times.
✓ Branch 1 taken 5758735 times.
6339767 if(scr==(currmap*MAPSCRS+currscr))
9266 581032 ret=(combobuf[tmpscr->data[pos]].walk&15)*10000;
9267
2/2
✓ Branch 0 taken 644433 times.
✓ Branch 1 taken 5114302 times.
5758735 else if(layr>-1)
9268 644433 ret=(combobuf[tmpscr2[layr].data[pos]].walk&15)*10000;
9269 5114302 else ret=(combobuf[TheMaps[scr].data[pos]].walk&15)*10000;
9270 }
9271
9272 }
9273 6342577 break;
9274
9275
9276
9277
9278 ///----------------------------------------------------------------------------------------------------//
9279 //Screen Information
9280
9281 #define GET_SCREENDATA_VAR_INT32(member, str) \
9282 { \
9283 ret = (tmpscr->member *10000); \
9284 } \
9285
9286 #define GET_SCREENDATA_VAR_INT16(member, str) \
9287 { \
9288 ret = (tmpscr->member *10000); \
9289 } \
9290
9291 #define GET_SCREENDATA_VAR_BYTE(member, str) \
9292 { \
9293 ret = (tmpscr->member *10000); \
9294 } \
9295
9296 #define GET_SCREENDATA_VAR_INDEX32(member, str, indexbound) \
9297 { \
9298 int32_t indx = ri->d[rINDEX] / 10000; \
9299 ret = (tmpscr->member[indx] *10000); \
9300 } \
9301
9302 #define GET_SCREENDATA_VAR_INDEX16(member, str, indexbound) \
9303 { \
9304 int32_t indx = ri->d[rINDEX] / 10000; \
9305 ret = (tmpscr->member[indx] *10000); \
9306 } \
9307
9308 #define GET_SCREENDATA_BYTE_INDEX(member, str, indexbound) \
9309 { \
9310 int32_t indx = ri->d[rINDEX] / 10000; \
9311 ret = (tmpscr->member[indx] *10000); \
9312 } \
9313
9314 //byte
9315 #define GET_SCREENDATA_LAYER_INDEX(member, str, indexbound) \
9316 { \
9317 int32_t indx = ri->d[rINDEX] / 10000; \
9318 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
9319 if(indx < 1 || indx > indexbound ) \
9320 { \
9321 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", str, indx); \
9322 ret = -10000; \
9323 } \
9324 else \
9325 { \
9326 ret = (tmpscr->member[indx-1] *10000); \
9327 } \
9328 } \
9329
9330
9331 #define GET_SCREENDATA_BOOL_INDEX(member, str, indexbound) \
9332 { \
9333 int32_t indx = ri->d[rINDEX] / 10000; \
9334 if(indx < 0 || indx > indexbound ) \
9335 { \
9336 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", (indx), str); \
9337 ret = -10000; \
9338 } \
9339 else \
9340 { \
9341 ret = (tmpscr->member[indx]?10000:0); \
9342 } \
9343 } \
9344
9345 #define GET_FFC_BOOL_INDEX(member, str, indexbound) \
9346 { \
9347 int32_t indx = ri->d[rINDEX] / 10000; \
9348 if(indx < 0 || indx > indexbound ) \
9349 { \
9350 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", (indx), str); \
9351 ret = -10000; \
9352 } \
9353 else \
9354 { \
9355 ret = (tmpscr->ffcs[indx].member?10000:0); \
9356 } \
9357 } \
9358
9359
9360 #define GET_SCREENDATA_FLAG(member, str, indexbound) \
9361 { \
9362 int32_t flag = (value/10000); \
9363 ret = (tmpscr->member&flag) ? 10000 : 0); \
9364 } \
9365
9366 case SCREENDATAVALID: GET_SCREENDATA_VAR_BYTE(valid, "Valid"); break; //b
9367 case SCREENDATAGUY: GET_SCREENDATA_VAR_BYTE(guy, "Guy"); break; //b
9368 case SCREENDATASTRING: GET_SCREENDATA_VAR_INT32(str, "String"); break; //w
9369 case SCREENDATAROOM: GET_SCREENDATA_VAR_BYTE(room, "RoomType"); break; //b
9370 case SCREENDATAITEM:
9371 {
9372 if(tmpscr->hasitem)
9373 ret = (tmpscr->item *10000);
9374 else ret = -10000;
9375 break;
9376 }
9377 case SCREENDATAHASITEM: GET_SCREENDATA_VAR_BYTE(hasitem, "HasItem"); break; //b
9378 case SCREENDATATILEWARPTYPE: GET_SCREENDATA_BYTE_INDEX(tilewarptype, "TileWarpType", 3); break; //b, 4 of these
9379 //case SCREENDATATILEWARPOVFLAGS: GET_SCREENDATA_VAR_BYTE(tilewarpoverlayflags, "TileWarpOverlayFlags"); break; //b, tilewarpoverlayflags
9380 case SCREENDATADOORCOMBOSET: GET_SCREENDATA_VAR_INT32(door_combo_set, "DoorComboSet"); break; //w
9381 case SCREENDATAWARPRETX: GET_SCREENDATA_BYTE_INDEX(warpreturnx, "WarpReturnX", 3); break; //b, 4 of these
9382 case SCREENDATAWARPRETY: GET_SCREENDATA_BYTE_INDEX(warpreturny, "WarpReturnY", 3); break; //b, 4 of these
9383 case SCREENDATAWARPRETURNC: GET_SCREENDATA_VAR_INT32(warpreturnc, "WarpReturnC"); break; //w
9384 case SCREENDATASTAIRX: GET_SCREENDATA_VAR_BYTE(stairx, "StairsX"); break; //b
9385 case SCREENDATASTAIRY: GET_SCREENDATA_VAR_BYTE(stairy, "StairsY"); break; //b
9386 case SCREENDATAITEMX: GET_SCREENDATA_VAR_BYTE(itemx, "ItemX"); break; //itemx
9387 case SCREENDATAITEMY: GET_SCREENDATA_VAR_BYTE(itemy, "ItemY"); break; //itemy
9388 514 case SCREENDATACOLOUR: GET_SCREENDATA_VAR_INT32(color, "CSet"); break; //w
9389 case SCREENDATAENEMYFLAGS: GET_SCREENDATA_VAR_BYTE(enemyflags, "EnemyFlags"); break; //b
9390 case SCREENDATADOOR: GET_SCREENDATA_BYTE_INDEX(door, "Door", 3); break; //b, 4 of these
9391 case SCREENDATATILEWARPDMAP: GET_SCREENDATA_VAR_INDEX32(tilewarpdmap, "TileWarpDMap", 3); break; //w, 4 of these
9392 case SCREENDATATILEWARPSCREEN: GET_SCREENDATA_BYTE_INDEX(tilewarpscr, "TileWarpScreen", 3); break; //b, 4 of these
9393 case SCREENDATAEXITDIR: GET_SCREENDATA_VAR_BYTE(exitdir, "ExitDir"); break; //b
9394 case SCREENDATAENEMY: GET_SCREENDATA_VAR_INDEX32(enemy, "Enemy", 9); break; //w, 10 of these
9395 case SCREENDATAPATTERN: GET_SCREENDATA_VAR_BYTE(pattern, "Pattern"); break; //b
9396 case SCREENDATASIDEWARPTYPE: GET_SCREENDATA_BYTE_INDEX(sidewarptype, "SideWarpType", 3); break; //b, 4 of these
9397 //case SCREENDATASIDEWARPOVFLAGS: GET_SCREENDATA_VAR_BYTE(sidewarpoverlayflags, "SideWarpOverlayFlags"); break; //b
9398 case SCREENDATAWARPARRIVALX: GET_SCREENDATA_VAR_BYTE(warparrivalx, "WarpArrivalX"); break; //b
9399 case SCREENDATAWARPARRIVALY: GET_SCREENDATA_VAR_BYTE(warparrivaly, "WarpArrivalY"); break; //b
9400 case SCREENDATAPATH: GET_SCREENDATA_BYTE_INDEX(path, "MazePath", 3); break; //b, 4 of these
9401 case SCREENDATASIDEWARPSC: GET_SCREENDATA_BYTE_INDEX(sidewarpscr, "SideWarpScreen", 3); break; //b, 4 of these
9402 case SCREENDATASIDEWARPDMAP: GET_SCREENDATA_VAR_INDEX32(sidewarpdmap, "SideWarpDMap", 3); break; //w, 4 of these
9403 case SCREENDATASIDEWARPINDEX: GET_SCREENDATA_VAR_BYTE(sidewarpindex, "SideWarpIndex"); break; //b
9404 case SCREENDATAUNDERCOMBO: GET_SCREENDATA_VAR_INT32(undercombo, "Undercombo"); break; //w
9405 case SCREENDATAUNDERCSET: GET_SCREENDATA_VAR_BYTE(undercset, "UnderCSet"); break; //b
9406 case SCREENDATACATCHALL: GET_SCREENDATA_VAR_INT32(catchall, "Catchall"); break; //W
9407
9408 case SCREENDATACSENSITIVE: GET_SCREENDATA_VAR_BYTE(csensitive, "CSensitive"); break; //B
9409 case SCREENDATANORESET: GET_SCREENDATA_VAR_INT32(noreset, "NoReset"); break; //W
9410 case SCREENDATANOCARRY: GET_SCREENDATA_VAR_INT32(nocarry, "NoCarry"); break; //W
9411
3/6
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 54 times.
54 case SCREENDATALAYERMAP: GET_SCREENDATA_LAYER_INDEX(layermap, "LayerMap", 6); break; //B, 6 OF THESE
9412 case SCREENDATALAYERSCREEN: GET_SCREENDATA_LAYER_INDEX(layerscreen, "LayerScreen", 6); break; //B, 6 OF THESE
9413 case SCREENDATALAYEROPACITY: GET_SCREENDATA_LAYER_INDEX(layeropacity, "LayerOpacity", 6); break; //B, 6 OF THESE
9414 case SCREENDATALAYERINVIS:
9415 {
9416 int32_t indx = ri->d[rINDEX] / 10000;
9417 if(indx < 0 || indx > 6 )
9418 {
9419 Z_scripterrlog("Invalid Index passed to Screen->LayerInvisible[]: %d\n", indx);
9420 ret = 0;
9421 }
9422 else
9423 {
9424 ret = ((tmpscr->hidelayers >> indx) & 1) *10000;
9425 }
9426 break;
9427 }
9428 case SCREENDATASCRIPTDRAWS:
9429 {
9430 int32_t indx = ri->d[rINDEX] / 10000;
9431 if(indx < 0 || indx > 7 )
9432 {
9433 Z_scripterrlog("Invalid Index passed to Screen->HideScriptLayer[]: %d\n", indx);
9434 ret = 0;
9435 }
9436 else
9437 {
9438 ret = ((tmpscr->hidescriptlayers >> indx) & 1) ? 0 : 10000;
9439 }
9440 break;
9441 }
9442 case SCREENDATATIMEDWARPTICS: GET_SCREENDATA_VAR_INT32(timedwarptics, "TimedWarpTimer"); break; //W
9443 case SCREENDATANEXTMAP: GET_SCREENDATA_VAR_BYTE(nextmap, "NextMap"); break; //B
9444 case SCREENDATANEXTSCREEN: GET_SCREENDATA_VAR_BYTE(nextscr, "NextScreen"); break; //B
9445 109824 case SCREENDATASECRETCOMBO: GET_SCREENDATA_VAR_INDEX32(secretcombo, "SecretCombo", 127); break; //W, 128 OF THESE
9446 case SCREENDATASECRETCSET: GET_SCREENDATA_BYTE_INDEX(secretcset, "SecretCSet", 127); break; //B, 128 OF THESE
9447 case SCREENDATASECRETFLAG: GET_SCREENDATA_BYTE_INDEX(secretflag, "SecretFlags", 127); break; //B, 128 OF THESE
9448 case SCREENDATAVIEWX: break;//GET_SCREENDATA_VAR_INT32(viewX, "ViewX"); break; //W
9449 case SCREENDATAVIEWY: break;//GET_SCREENDATA_VAR_INT32(viewY, "ViewY"); break; //W
9450 case SCREENDATASCREENWIDTH: break;//GET_SCREENDATA_VAR_BYTE(scrWidth, "Width"); break; //B
9451 case SCREENDATASCREENHEIGHT: break;//GET_SCREENDATA_VAR_BYTE(scrHeight, "Height"); break; //B
9452 case SCREENDATAENTRYX: GET_SCREENDATA_VAR_BYTE(entry_x, "EntryX"); break; //B
9453 case SCREENDATAENTRYY: GET_SCREENDATA_VAR_BYTE(entry_y, "EntryY"); break; //B
9454 //Number of ffcs that are in use (have valid data
9455 case SCREENDATANUMFF:
9456 {
9457 uint32_t indx = ri->d[rINDEX] / 10000;
9458 if (!indx || indx > MAXFFCS)
9459 {
9460 Z_scripterrlog("Invalid Index passed to Screen->NumFFCs[%d].\n Valid indices are 1 through %d.\n", indx, MAXFFCS);
9461 ret = 0;
9462 }
9463 else
9464 {
9465 --indx;
9466 ret = (tmpscr->ffcs[indx].getData() != 0) ? 10000 : 0;
9467 }
9468 break;
9469 }
9470 //inita //INT32, 32 OF THESE, EACH WITH 2
9471 case SCREENDATAFFINITIALISED: {
9472 int32_t indx = ri->d[rINDEX] / 10000;
9473 if (indx < 0 || indx > MAXFFCS-1)
9474 {
9475 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", indx, "FFCRunning");
9476 ret = -10000;
9477 }
9478 else
9479 {
9480 ret = get_script_engine_data(ScriptType::FFC, indx).initialized ? 10000 : 0;
9481 }
9482 }
9483 break;
9484
9485 case SCREENDATASCRIPTENTRY: GET_SCREENDATA_VAR_INT32(script_entry, "ScriptEntry"); break; //W
9486 case SCREENDATASCRIPTOCCUPANCY: GET_SCREENDATA_VAR_INT32(script_occupancy, "ScriptOccupancy"); break;//W
9487 case SCREENDATASCRIPTEXIT: GET_SCREENDATA_VAR_INT32(script_exit, "ExitScript"); break; //W
9488 case SCREENDATAOCEANSFX: GET_SCREENDATA_VAR_BYTE(oceansfx, "OceanSFX"); break; //B
9489 case SCREENDATABOSSSFX: GET_SCREENDATA_VAR_BYTE(bosssfx, "BossSFX"); break; //B
9490 1 case SCREENDATASECRETSFX: GET_SCREENDATA_VAR_BYTE(secretsfx, "SecretSFX"); break; //B
9491 case SCREENDATAHOLDUPSFX: GET_SCREENDATA_VAR_BYTE(holdupsfx, "ItemSFX"); break; //B
9492 case SCREENDATASCREENMIDI:
9493 {
9494 ret = ((tmpscr->screen_midi+(MIDIOFFSET_MAPSCR-MIDIOFFSET_ZSCRIPT)) *10000);
9495 break;
9496 }
9497 case SCREENDATALENSLAYER: GET_SCREENDATA_VAR_BYTE(lens_layer, "LensLayer"); break; //B, OLD QUESTS ONLY?
9498
9499 case SCREENSIDEWARPID:
9500 {
9501 int32_t indx = ri->d[rINDEX] / 10000;
9502
9503 ret = (((tmpscr->flags2 >> indx) & 1)
9504 ? (tmpscr->sidewarpindex >> (2*indx)) & 3 //Return which warp is set
9505 : -1 //Returns -1 if no warp is set
9506 )*10000;
9507 break;
9508 }
9509
9510 case SCREENDATATILEWARPOVFLAGS:
9511 {
9512 int32_t indx = ri->d[rINDEX] / 10000;
9513 if ( ((unsigned)indx) > 3 )
9514 {
9515 Z_scripterrlog("Invalid index passed to TileWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
9516 ret = 0;
9517 }
9518 else
9519 {
9520 ret = (tmpscr->tilewarpoverlayflags & (1<<indx))?10000:0;
9521 }
9522 break;
9523 }
9524
9525 case SCREENDATASIDEWARPOVFLAGS:
9526 {
9527 int32_t indx = ri->d[rINDEX] / 10000;
9528 if ( ((unsigned)indx) > 3 )
9529 {
9530 Z_scripterrlog("Invalid index passed to SideWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
9531 ret = 0;
9532 }
9533 else
9534 {
9535 ret = (tmpscr->sidewarpoverlayflags & (1<<indx))?10000:0;
9536 }
9537 break;
9538 }
9539
9540 case SCREENDATATWARPRETSQR:
9541 {
9542 int32_t indx = ri->d[rINDEX] / 10000;
9543 if ( ((unsigned)indx) > 3)
9544 {
9545 ret = -10000;
9546 Z_scripterrlog("Invalid Array Index passed to Screen->TileWarpReturnSquare[]: %d\n", indx);
9547
9548 }
9549 else
9550 {
9551 ret = ((tmpscr->warpreturnc>>(indx*2))&3) * 10000;
9552 }
9553 break;
9554 }
9555
9556
9557 case SCREENDATASWARPRETSQR:
9558 {
9559 int32_t indx = ri->d[rINDEX] / 10000;
9560 if ( ((unsigned)indx) > 3)
9561 {
9562 ret = -10000;
9563 Z_scripterrlog("Invalid Array Index passed to Screen->SideWarpReturnSquare[]: %d\n", indx);
9564
9565 }
9566 else
9567 {
9568 ret = ((tmpscr->warpreturnc>>(8+(indx*2)))&3) * 10000;
9569 }
9570 break;
9571 }
9572
9573 case SCREENDATAFLAGS:
9574 {
9575 int32_t flagid = (ri->d[rINDEX])/10000;
9576 //bool valtrue = ( value ? 10000 : 0);
9577 switch(flagid)
9578 {
9579 case 0: ret = (tmpscr->flags * 10000); break;
9580 case 1: ret = (tmpscr->flags2 * 10000); break;
9581 case 2: ret = (tmpscr->flags3 * 10000); break;
9582 case 3: ret = (tmpscr->flags4 * 10000); break;
9583 case 4: ret = (tmpscr->flags5 * 10000); break;
9584 case 5: ret = (tmpscr->flags6 * 10000); break;
9585 case 6: ret = (tmpscr->flags7 * 10000); break;
9586 case 7: ret = (tmpscr->flags8 * 10000); break;
9587 case 8: ret = (tmpscr->flags9 * 10000); break;
9588 case 9: ret = (tmpscr->flags10 * 10000); break;
9589 default:
9590 {
9591 Z_scripterrlog("Invalid index passed to mapdata->flags[]: %d\n", flagid);
9592 ret = -10000;
9593 break;
9594
9595 }
9596 }
9597 break;
9598 //GET_SCREENDATA_BYTE_INDEX //B, 11 OF THESE, flags, flags2-flags10
9599 }
9600
9601 case SCREENSECRETSTRIGGERED:
9602 {
9603 910 ret = triggered_screen_secrets ? 10000L : 0L;
9604 910 break;
9605 }
9606
9607 case SHOWNMSG:
9608 {
9609 ret = ((msg_active || msg_onscreen) ? msgstr : 0) * 10000L;
9610 break;
9611 }
9612
9613 case SDD:
9614 {
9615
2/2
✓ Branch 0 taken 387442 times.
✓ Branch 1 taken 2580 times.
390022 int32_t di = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
9616 390022 ret=FFScript::get_screen_d(di, ri->d[rINDEX]/10000);
9617 }
9618 390022 break;
9619
9620 case SDDD:
9621 43250 ret=FFScript::get_screen_d((ri->d[rINDEX])/10000 + ((get_currdmap())<<7), ri->d[rINDEX2] / 10000);
9622 43250 break;
9623
9624 case LINKOTILE:
9625 ret=FFCore.getHeroOTile(ri->d[rINDEX]/10000, ri->d[rINDEX2] / 10000);
9626 break;
9627
9628 case SDDDD:
9629 3 ret=FFScript::get_screen_d(ri->d[rINDEX2] / 10000 + ((ri->d[rINDEX]/10000)<<7), ri->d[rEXP1] / 10000);
9630 3 break;
9631
9632 case SCRDOORD:
9633 4 ret=tmpscr->door[ri->d[rINDEX]/10000]*10000;
9634 4 break;
9635
9636 case SCREENSCRIPT:
9637 ret=tmpscr->script*10000;
9638 break;
9639
9640 case SCREENINITD:
9641 ret = tmpscr->screeninitd[ri->d[rINDEX]/10000];
9642 break;
9643
9644 case MAPDATAINITDARRAY:
9645 {
9646 if ( ri->mapsref == MAX_SIGNED_32 )
9647 {
9648 Z_scripterrlog("Script attempted to use a mapdata->InitD[%d] on a pointer that is uninitialised\n",ri->d[rINDEX]/10000);
9649 break;
9650 }
9651 else
9652 {
9653 mapscr *m = GetMapscr(ri->mapsref);
9654 ret = m->screeninitd[ri->d[rINDEX]/10000];
9655 }
9656 break;
9657 }
9658
9659 case MAPDATALAYERINVIS:
9660 {
9661 int32_t indx = ri->d[rINDEX] / 10000;
9662 if(indx < 0 || indx > 6 )
9663 {
9664 Z_scripterrlog("Invalid Index passed to mapdata->LayerInvisible[]: %d\n", indx);
9665 ret = 0;
9666 }
9667 else
9668 {
9669 if ( ri->mapsref == MAX_SIGNED_32 )
9670 {
9671 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","LayerInvisible");
9672 ret = -10000;
9673 }
9674 else
9675 {
9676 mapscr *m = GetMapscr(ri->mapsref);
9677 ret = ((m->hidelayers >> indx) & 1) *10000;
9678 }
9679 }
9680 break;
9681 }
9682 case MAPDATASCRIPTDRAWS:
9683 {
9684 int32_t indx = ri->d[rINDEX] / 10000;
9685 if(indx < 0 || indx > 7 )
9686 {
9687 Z_scripterrlog("Invalid Index passed to mapdata->DisableScriptDraws[]: %d\n", indx);
9688 ret = 0;
9689 }
9690 else
9691 {
9692 if ( ri->mapsref == MAX_SIGNED_32 )
9693 {
9694 Z_scripterrlog("Script attempted to use a mapdata->DisableScriptDraws on a pointer that is uninitialised\n");
9695 ret = -10000;
9696 }
9697 else
9698 {
9699 mapscr *m = GetMapscr(ri->mapsref);
9700 ret = ((m->hidescriptlayers >> indx) & 1) ? 0 : 10000;
9701 }
9702 }
9703 break;
9704 }
9705
9706 //These use the same method as GetScreenD -Z
9707 case SCREENWIDTH:
9708 // ret=FFScript::get_screenWidth(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9709 break;
9710
9711 case SCREENHEIGHT:
9712 // ret=FFScript::get_screenHeight(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9713 break;
9714
9715 case SCREENVIEWX:
9716 // ret=get_screenViewX(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9717 break;
9718
9719 case SCREENVIEWY:
9720 // ret=get_screenViewY(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9721 break;
9722
9723 case SCREENGUY:
9724 ret=get_screenGuy(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9725 break;
9726
9727 case SCREENSTRING:
9728 ret=get_screenString(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9729 break;
9730
9731 case SCREENROOM:
9732 ret=get_screenRoomtype(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9733 break;
9734
9735 case SCREENENTX:
9736 ret=get_screenEntryX(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9737 break;
9738
9739 case SCREENENTY:
9740 ret=get_screenEntryY(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9741 break;
9742
9743 case SCREENITEM:
9744 ret=get_screenitem(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9745 break;
9746
9747 case SCREENUNDCMB:
9748 ret=get_screenundercombo(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9749 break;
9750
9751 case SCREENUNDCST:
9752 ret=get_screenundercset(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9753 break;
9754
9755 case SCREENCATCH:
9756 ret=get_screenatchall(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9757 break;
9758
9759
9760 case LIT:
9761 10246 ret= darkroom ? 0 : 10000;
9762 10246 break;
9763
9764 case WAVY:
9765 7214 ret = wavy*10000;
9766 7214 break;
9767
9768 case QUAKE:
9769 2272 ret = quakeclk*10000;
9770 2272 break;
9771
9772 case SCREENFLAGSD:
9773 6641186 ret = get_screenflags(tmpscr,vbound(ri->d[rINDEX] / 10000,0,9));
9774 6641186 break;
9775
9776 case SCREENEFLAGSD:
9777 1524194 ret = get_screeneflags(tmpscr,vbound(ri->d[rINDEX] / 10000,0,2));
9778 1524194 break;
9779
9780 case NPCCOUNT:
9781 11321068 ret = guys.Count()*10000;
9782 11321068 break;
9783
9784 case ROOMDATA:
9785 ret = tmpscr->catchall*10000;
9786 break;
9787
9788 case ROOMTYPE:
9789 ret = tmpscr->room*10000;
9790 break;
9791
9792 case PUSHBLOCKX:
9793
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 229787 times.
229939 ret = mblock2.active() ? int32_t(mblock2.x)*10000 : -10000;
9794 229939 break;
9795
9796 case PUSHBLOCKY:
9797
1/2
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
91 ret = mblock2.active() ? int32_t(mblock2.y)*10000 : -10000;
9798 91 break;
9799
9800 case PUSHBLOCKLAYER:
9801 ret = mblock2.active() ? int32_t(mblock2.blockLayer)*10000 : -10000;
9802 break;
9803
9804 case PUSHBLOCKCOMBO:
9805 ret = mblock2.bcombo*10000;
9806 break;
9807
9808 case PUSHBLOCKCSET:
9809 ret = mblock2.cs*10000;
9810 break;
9811
9812 case UNDERCOMBO:
9813 1 ret = tmpscr->undercombo*10000;
9814 1 break;
9815
9816 case UNDERCSET:
9817 1 ret = tmpscr->undercset*10000;
9818 1 break;
9819
9820 //Creates an lweapon using an iemdata struct values to generate its properties.
9821 //Useful in conjunction with the new weapon editor.
9822 case CREATELWPNDX:
9823 {
9824 //Z_message("Trying to get Player->SetExtend().\n");
9825 int32_t ID = (ri->d[rINDEX] / 10000);
9826 int32_t itemid = (ri->d[rINDEX2]/10000);
9827 itemid = vbound(itemid,0,(MAXITEMS-1));
9828
9829 //Z_scripterrlog("GetHeroExtend rid->[2] is (%i), trying to use for '%s'\n", ri->d[rEXP1], "ri->d[rEXP1]");
9830 //Z_scripterrlog("GetHeroExtend rid->[1] is (%i), trying to use for '%s'\n", state, "state");
9831 //Z_scripterrlog("GetHeroExtend rid->[0] is (%i), trying to use for '%s'\n", dir, "dir");
9832 if ( Lwpns.Count() < 256 )
9833 {
9834
9835 Lwpns.add
9836 (
9837 new weapon
9838 (
9839 (zfix)0, /*X*/
9840 (zfix)0, /*Y*/
9841 (zfix)0, /*Z*/
9842 ID, /*id*/
9843 0, /*type*/
9844 0, /*power*/
9845 0, /*dir*/
9846 -1, /*Parentid*/
9847 Hero.getUID(), /*prntid*/
9848 false, /*isdummy*/
9849 1, /*script_gen*/
9850 1, /*islwpn*/
9851 (ID==wWind?1:0) /*special*/
9852 )
9853 );
9854 ri->lwpn = Lwpns.spr(Lwpns.Count() - 1)->getUID();
9855
9856 weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //last created
9857 //w->LOADGFX(FFCore.getDefWeaponSprite(ID)); //What the fuck Zoria, this broke old quests...
9858 w->ScriptGenerated = 1;
9859 w->isLWeapon = 1;
9860 if(ID == wWind) w->specialinfo = 1;
9861 //weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //last created
9862 //w->LOADGFX(FFCore.getDefWeaponSprite(ID)); //not needed here because this has access to wpn->prent
9863 }
9864 else
9865 {
9866 Z_scripterrlog("Tried to create too many LWeapons on the screen. The current LWeapon count is: %d\n", Lwpns.Count());
9867 ri->lwpn = 0;
9868 }
9869
9870 /* Z_scripterrlog("CreateLWeaponDx ri->d[rINDEX] is (%i), trying to use for '%s'\n", ID, "ID");
9871 Z_scripterrlog("CreateLWeaponDx ri->d[rINDEX2] is (%i), trying to use for '%s'\n", itemid, "itemid");
9872 Z_scripterrlog("CreateLWeaponDx ri->lwpn is (%i), trying to use for '%s'\n", ri->lwpn, "ri->lwpn"); */
9873
9874 ret = ri->lwpn;
9875 }
9876 break;
9877
9878 /*
9879 //Screen->CollisionDx(int32_t enemy_index, int32_t lweapon_type, int32_t power, int32_t x, int32_t y, int32_t weapon_dir, int32_t parent_item);
9880 //Handles collision between an npc at screen index 'enemy_index', and an arbitrary lweapon that may or may not exist.
9881 //Does damage, and returns true a value collision is valid. Returns a different value otherwise.
9882
9883 // take damage or ignore it
9884 // -1: damage (if any) dealt
9885 // 1: blocked
9886 // 0: weapon passes through unhindered
9887 // 2: heal enemy? -ZoriaRPG
9888
9889 //THis function should automatically check for shields blocking the weapon, and calculate enemy defences.
9890 //In theory, scritped swords, and other melee weapons could use this, as coudl any weapon, and it may simplify
9891 //collision routines.
9892 case COLLISIONDX:
9893 {
9894 //Z_message("Trying to get Player->SetExtend().\n");
9895 int32_t index = (ri->d[rINDEX] / 10000);
9896 int32_t lweapon_type = (ri->d[rINDEX2] / 10000);
9897 int32_t power = (ri->d[rEXP1]/10000);
9898
9899 int32_t wpnx = ri->4[3]/10000, wpny = ri->d[rSFRAME]/10000;
9900 int32_t dir = ri->d[rNUL]/10000;
9901 int32_t parentitem = (ri->d[rSFTEMP]/10000);
9902 lweapon_type = vbound(lweapon_type,0,40); //Are we at 40, or higher now>
9903 parentitem = vbound(itemid,0,255);
9904
9905 //Log the stack events:
9906 Z_scripterrlog("CollisionDx ri->d[rINDEX] is (%i), trying to use for '%s'\n", index, "index");
9907 Z_scripterrlog("CollisionDx ri->d[rINDEX2] is (%i), trying to use for '%s'\n", lweapon_type, "lweapon_type");
9908 Z_scripterrlog("CollisionDx ri->d[rEXP1] is (%i), trying to use for '%s'\n", power, "power");
9909 Z_scripterrlog("CollisionDx ri->d[rEXP2] is (%i), trying to use for '%s'\n", wpnx, "wpnx");
9910 Z_scripterrlog("CollisionDx ri->d[rSFRAME] is (%i), trying to use for '%s'\n", wpny, "wpny");
9911 Z_scripterrlog("CollisionDx ri->d[rNUL] is (%i), trying to use for '%s'\n", dir, "dir");
9912 Z_scripterrlog("CollisionDx ri->d[rINDEX] is (%i), trying to use for '%s'\n", parentitem, "parentitem");
9913
9914 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,lweapon_type,0,power,dir,parentitem,-1,false);
9915 int32_t retval = ((enemy*)guys.spr(index))->takehit(w);
9916 //TakeHit, as I recall, applies damage and returns the hit status. Gold.
9917 delete w;
9918 ret = retval;
9919 }
9920 break;
9921
9922 */
9923 case DEBUGREFFFC:
9924 {
9925 int32_t r = -1;
9926 if ( ri->ffcref ) r = ri->ffcref;
9927 ret = r * 10000;
9928 break;
9929 }
9930
9931 case DEBUGREFITEM:
9932 {
9933 int32_t r = -1;
9934 if ( ri->itemref ) r = ri->itemref;
9935 ret = r * 10000;
9936 break;
9937 }
9938
9939 case DEBUGREFITEMDATA:
9940 {
9941 int32_t r = -1;
9942 if ( ri->idata ) r = ri->idata;
9943 ret = r * 10000;
9944 break;
9945 }
9946
9947 case DEBUGREFLWEAPON:
9948 {
9949 int32_t r = -1;
9950 if ( ri->lwpn ) r = ri->lwpn;
9951 ret = r * 10000;
9952 break;
9953 }
9954
9955 case DEBUGREFEWEAPON:
9956 {
9957 int32_t r = -1;
9958 if ( ri->ewpn ) r = ri->ewpn;
9959 ret = r * 10000;
9960 break;
9961 }
9962
9963 case DEBUGREFNPC:
9964 {
9965 int32_t r = -1;
9966 if ( ri->guyref ) r = ri->guyref;
9967 ret = r * 10000;
9968 break;
9969 }
9970
9971 case DEBUGSP:
9972 {
9973 ret = SH::read_stack(ri->sp) * 10000;
9974 break;
9975 }
9976 case DEBUGGDR:
9977 {
9978 int32_t a = vbound(ri->d[rINDEX]/10000,0,15);
9979 int32_t r = -1;
9980 if ( game->global_d[a] ) r = game->global_d[a];
9981 ret = r * 10000;
9982 break;
9983 }
9984
9985 ///----------------------------------------------------------------------------------------------------//
9986 //New Datatype Variables
9987
9988 ///----------------------------------------------------------------------------------------------------//
9989 //spritedata sp-> Variables
9990
9991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 case SPRITEDATATILE: GET_SPRITEDATA_VAR_INT(tile, "Tile") break;
9992 case SPRITEDATAMISC: GET_SPRITEDATA_VAR_INT(misc, "Misc") break;
9993 case SPRITEDATACSETS:
9994 {
9995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
9996 {
9997 ret = -10000;
9998 Z_scripterrlog("Invalid Sprite ID passed to spritedata->CSet: %d\n", (ri->spritesref*10000));
9999 }
10000 else
10001 16 ret = ((wpnsbuf[ri->spritesref].csets & 0xF) * 10000);
10002 16 break;
10003 }
10004 case SPRITEDATAFLCSET:
10005 {
10006 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
10007 {
10008 ret = -10000;
10009 Z_scripterrlog("Invalid Sprite ID passed to spritedata->%s: %d\n", (ri->spritesref*10000), "FlashCSet");
10010 break;
10011 }
10012 ret = (((wpnsbuf[ri->spritesref].csets & 0xF0)>>4) * 10000);
10013 break;
10014 }
10015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 case SPRITEDATAFRAMES: GET_SPRITEDATA_VAR_INT(frames, "Frames") break;
10016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 case SPRITEDATASPEED: GET_SPRITEDATA_VAR_INT(speed, "Speed") break;
10017 case SPRITEDATATYPE: GET_SPRITEDATA_VAR_INT(type, "Type") break;
10018 case SPRITEDATAFLAGS:
10019 {
10020 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
10021 {
10022 ret = 0;
10023 Z_scripterrlog("Invalid Sprite ID passed to spritedata->Flags[]: %d\n", (ri->spritesref*10000));
10024 break;
10025 }
10026 int32_t index = ri->d[rINDEX]/10000;
10027 if(unsigned(index) >= 5)
10028 {
10029 ret = 0;
10030 Z_scripterrlog("Invalid index passed to spritedata->Flags[]: %d\n", index);
10031 break;
10032 }
10033 ret = (wpnsbuf[ri->spritesref].misc & (1<<index)) ? 10000 : 0;
10034 break;
10035 }
10036 case SPRITEDATAID:
10037 {
10038 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
10039 {
10040 ret = -10000;
10041 Z_scripterrlog("Invalid Sprite ID passed to spritedata->ID: %d\n", (ri->spritesref*10000));
10042 break;
10043 }
10044 ret = ri->spritesref*10000;
10045 break;
10046 }
10047
10048 ///----------------------------------------------------------------------------------------------------//
10049 //mapdata m-> variables
10050 #define GET_MAPDATA_VAR_INT32(member, str) \
10051 { \
10052 if ( mapscr *m = GetMapscr(ri->mapsref) ) \
10053 { \
10054 ret = (m->member *10000); \
10055 } \
10056 else \
10057 { \
10058 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10059 ret = -10000; \
10060 } \
10061 } \
10062
10063 #define GET_MAPDATA_VAR_INT16(member, str) \
10064 { \
10065 if ( mapscr *m = GetMapscr(ri->mapsref) ) \
10066 { \
10067 ret = (m->member *10000); \
10068 } \
10069 else \
10070 { \
10071 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10072 ret = -10000; \
10073 } \
10074 } \
10075
10076 #define GET_MAPDATA_VAR_BYTE(member, str) \
10077 { \
10078 if ( mapscr *m = GetMapscr(ri->mapsref) ) \
10079 { \
10080 ret = (m->member *10000); \
10081 } \
10082 else \
10083 { \
10084 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10085 ret = -10000; \
10086 } \
10087 } \
10088
10089 #define GET_MAPDATA_VAR_INDEX32(member, str, indexbound) \
10090 { \
10091 int32_t indx = ri->d[rINDEX] / 10000; \
10092 if(indx < 0 || indx > indexbound ) \
10093 { \
10094 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
10095 ret = -10000; \
10096 } \
10097 else \
10098 { \
10099 if (mapscr *m = GetMapscr(ri->mapsref)) \
10100 { \
10101 ret = (m->member[indx] *10000); \
10102 } \
10103 else \
10104 { \
10105 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10106 ret = -10000; \
10107 } \
10108 } \
10109 } \
10110
10111 #define GET_MAPDATA_VAR_INDEX16(member, str, indexbound) \
10112 { \
10113 int32_t indx = ri->d[rINDEX] / 10000; \
10114 if(indx < 0 || indx > indexbound ) \
10115 { \
10116 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
10117 ret = -10000; \
10118 } \
10119 else \
10120 { \
10121 if (mapscr *m = GetMapscr(ri->mapsref)) \
10122 { \
10123 ret = (m->member[indx] *10000); \
10124 } \
10125 else \
10126 { \
10127 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10128 ret = -10000; \
10129 } \
10130 } \
10131 } \
10132
10133 #define GET_MAPDATA_BYTE_INDEX(member, str, indexbound) \
10134 { \
10135 int32_t indx = ri->d[rINDEX] / 10000; \
10136 if(indx < 0 || indx > indexbound ) \
10137 { \
10138 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
10139 ret = -10000; \
10140 } \
10141 else \
10142 { \
10143 if (mapscr *m = GetMapscr(ri->mapsref)) \
10144 { \
10145 ret = (m->member[indx] *10000); \
10146 } \
10147 else \
10148 { \
10149 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10150 ret = -10000; \
10151 } \
10152 } \
10153 } \
10154
10155 /*
10156 #define GET_MAPDATA_LAYER_INDEX(member, str, indexbound) \
10157 { \
10158 int32_t indx = ri->d[rINDEX] / 10000; \
10159 mapscr *m = GetMapscr(ri->mapsref); \
10160 if ( indx == 0 ) \
10161 { \
10162 \
10163 } \
10164 else \
10165 { \
10166 ret = (m->member[indx-1] *10000); \
10167 } \
10168 } \
10169 */
10170
10171 #define GET_MAPDATA_LAYER_INDEX(member, str, indexbound) \
10172 { \
10173 int32_t indx = ri->d[rINDEX] / 10000; \
10174 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
10175 if(indx < 1 || indx > indexbound ) \
10176 { \
10177 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
10178 ret = -10000; \
10179 } \
10180 else \
10181 { \
10182 if (mapscr *m = GetMapscr(ri->mapsref)) \
10183 { \
10184 ret = (m->member[indx-1] *10000); \
10185 } \
10186 else \
10187 { \
10188 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10189 ret = -10000; \
10190 } \
10191 } \
10192 } \
10193
10194 #define GET_MAPDATA_BOOL_INDEX(member, str, indexbound) \
10195 { \
10196 int32_t indx = ri->d[rINDEX] / 10000; \
10197 if(indx < 0 || indx > indexbound ) \
10198 { \
10199 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
10200 ret = -10000; \
10201 } \
10202 else \
10203 { \
10204 if (mapscr *m = GetMapscr(ri->mapsref)) \
10205 { \
10206 ret = (m->member[indx]?10000:0); \
10207 } \
10208 else \
10209 { \
10210 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10211 ret = -10000; \
10212 } \
10213 } \
10214 } \
10215
10216 #define GET_FFC_MAPDATA_BOOL_INDEX(member, str, indexbound) \
10217 { \
10218 int32_t indx = ri->d[rINDEX] / 10000; \
10219 if(indx < 0 || indx > indexbound ) \
10220 { \
10221 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
10222 ret = -10000; \
10223 } \
10224 else \
10225 { \
10226 if (mapscr *m = GetMapscr(ri->mapsref)) \
10227 { \
10228 ret = (m->ffcs[indx].member?10000:0); \
10229 } \
10230 else \
10231 { \
10232 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10233 ret = -10000; \
10234 } \
10235 } \
10236 } \
10237
10238 #define GET_MAPDATA_FLAG(member, str) \
10239 { \
10240 int32_t flag = (value/10000); \
10241 if (mapscr *m = GetMapscr(ri->mapsref)) \
10242 { \
10243 ret = (m->member&flag) ? 10000 : 0); \
10244 } \
10245 else \
10246 { \
10247 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10248 ret = -10000; \
10249 } \
10250 } \
10251
10252 #define GET_SCREENDATA_COMBO_VAR(member, str) \
10253 { \
10254 if (mapscr *m = GetMapscr(ri->mapsref)) \
10255 { \
10256 int32_t pos = ri->d[rINDEX] / 10000; \
10257 if(BC::checkComboPos(pos, str) != SH::_NoError) \
10258 ret = -10000; \
10259 else \
10260 ret = m->member[pos]*10000; \
10261 } \
10262 else \
10263 { \
10264 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10265 ret = -10000; \
10266 } \
10267 } \
10268
10269 #define GET_MAPDATA_COMBO_VAR_BUF(member, str) \
10270 { \
10271 if (mapscr *m = GetMapscr(ri->mapsref)) \
10272 { \
10273 int32_t pos = ri->d[rINDEX] / 10000; \
10274 if(BC::checkComboPos(pos, str) != SH::_NoError) \
10275 ret = -10000; \
10276 else \
10277 ret = combobuf[m->data[pos]].member * 10000; \
10278 } \
10279 else \
10280 { \
10281 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
10282 ret = -10000; \
10283 } \
10284 } \
10285
10286 #define GET_MAPDATA_FFCPOS_INDEX32(member, str, indexbound) \
10287 { \
10288 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
10289 if(indx < 0 || indx > indexbound ) \
10290 { \
10291 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
10292 ret = -10000; \
10293 } \
10294 else if (mapscr *m = GetMapscr(ri->mapsref)) \
10295 { \
10296 ret = (m->ffcs[indx].member).getZLong(); \
10297 } \
10298 else \
10299 { \
10300 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
10301 ret = -10000; \
10302 } \
10303 } \
10304
10305 #define GET_MAPDATA_FFC_INDEX32(member, str, indexbound) \
10306 { \
10307 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
10308 if(indx < 0 || indx > indexbound ) \
10309 { \
10310 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
10311 ret = -10000; \
10312 } \
10313 else if (mapscr *m = GetMapscr(ri->mapsref)) \
10314 { \
10315 ret = (m->ffcs[indx].member)*10000; \
10316 } \
10317 else \
10318 { \
10319 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
10320 ret = -10000; \
10321 } \
10322 } \
10323
10324 #define GET_MAPDATA_FFC_INDEX32(member, str, indexbound) \
10325 { \
10326 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
10327 if(indx < 0 || indx > indexbound ) \
10328 { \
10329 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
10330 ret = -10000; \
10331 } \
10332 else if (mapscr *m = GetMapscr(ri->mapsref)) \
10333 { \
10334 ret = (m->ffcs[indx].member)*10000; \
10335 } \
10336 else \
10337 { \
10338 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
10339 ret = -10000; \
10340 } \
10341 } \
10342
10343 case LOADMAPDATA:
10344 6554876 ret=FFScript::loadMapData();
10345 6554876 break;
10346
10347 case NPCCOLLISION:
10348 ret=FFCore.npc_collision();
10349 break;
10350
10351 case NPCLINEDUP:
10352 ret=FFCore.npc_linedup();
10353 break;
10354
10355 case CREATEBITMAP:
10356 {
10357 3670 ret=FFCore.do_create_bitmap();
10358 3670 break;
10359 }
10360
10361
10362
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 case MAPDATAVALID: GET_MAPDATA_VAR_BYTE(valid, "Valid"); break; //b
10363 case MAPDATAGUY: GET_MAPDATA_VAR_BYTE(guy, "Guy"); break; //b
10364 case MAPDATASTRING: GET_MAPDATA_VAR_INT32(str, "String"); break; //w
10365 case MAPDATAROOM: GET_MAPDATA_VAR_BYTE(room, "RoomType"); break; //b
10366 case MAPDATAITEM:
10367 {
10368 if ( mapscr *m = GetMapscr(ri->mapsref) )
10369 {
10370 if(m->hasitem)
10371 ret = (m->item *10000);
10372 else ret = -10000;
10373 }
10374 else
10375 {
10376 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Item"); \
10377 ret = -10000;
10378 }
10379 break;
10380 }
10381 case MAPDATAHASITEM: GET_MAPDATA_VAR_BYTE(hasitem, "HasItem"); break; //b
10382 case MAPDATATILEWARPTYPE: GET_MAPDATA_BYTE_INDEX(tilewarptype, "TileWarpType", 3); break; //b, 4 of these
10383 //case MAPDATATILEWARPOVFLAGS: GET_MAPDATA_VAR_BYTE(tilewarpoverlayflags, "TileWarpOverlayFlags"); break; //b, tilewarpoverlayflags
10384 case MAPDATADOORCOMBOSET: GET_MAPDATA_VAR_INT32(door_combo_set, "DoorComboSet"); break; //w
10385 case MAPDATAWARPRETX: GET_MAPDATA_BYTE_INDEX(warpreturnx, "WarpReturnX", 3); break; //b, 4 of these
10386 case MAPDATAWARPRETY: GET_MAPDATA_BYTE_INDEX(warpreturny, "WarpReturnY", 3); break; //b, 4 of these
10387 case MAPDATAWARPRETURNC: GET_MAPDATA_VAR_INT32(warpreturnc, "WarpReturnC"); break; //w
10388 case MAPDATASTAIRX: GET_MAPDATA_VAR_BYTE(stairx, "StairsX"); break; //b
10389 case MAPDATASTAIRY: GET_MAPDATA_VAR_BYTE(stairy, "StairsY"); break; //b
10390 case MAPDATAITEMX: GET_MAPDATA_VAR_BYTE(itemx, "ItemX"); break; //itemx
10391 case MAPDATAITEMY: GET_MAPDATA_VAR_BYTE(itemy, "ItemY"); break; //itemy
10392
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 case MAPDATACOLOUR: GET_MAPDATA_VAR_INT32(color, "CSet"); break; //w
10393 case MAPDATAENEMYFLAGS: GET_MAPDATA_VAR_BYTE(enemyflags, "EnemyFlags"); break; //b
10394 case MAPDATADOOR: GET_MAPDATA_BYTE_INDEX(door, "Door", 3); break; //b, 4 of these
10395 case MAPDATATILEWARPDMAP: GET_MAPDATA_VAR_INDEX32(tilewarpdmap, "TileWarpDMap", 3); break; //w, 4 of these
10396 case MAPDATATILEWARPSCREEN: GET_MAPDATA_BYTE_INDEX(tilewarpscr, "TileWarpScreen", 3); break; //b, 4 of these
10397 case MAPDATAEXITDIR: GET_MAPDATA_VAR_BYTE(exitdir, "ExitDir"); break; //b
10398 case MAPDATAENEMY: GET_MAPDATA_VAR_INDEX32(enemy, "Enemy", 9); break; //w, 10 of these
10399 case MAPDATAPATTERN: GET_MAPDATA_VAR_BYTE(pattern, "Pattern"); break; //b
10400 case MAPDATASIDEWARPTYPE: GET_MAPDATA_BYTE_INDEX(sidewarptype, "SideWarpType", 3); break; //b, 4 of these
10401 //case MAPDATASIDEWARPOVFLAGS: GET_MAPDATA_VAR_BYTE(sidewarpoverlayflags, "SideWarpOverlayFlags"); break; //b
10402 case MAPDATAWARPARRIVALX: GET_MAPDATA_VAR_BYTE(warparrivalx, "WarpArrivalX"); break; //b
10403 case MAPDATAWARPARRIVALY: GET_MAPDATA_VAR_BYTE(warparrivaly, "WarpArrivalY"); break; //b
10404 case MAPDATAPATH: GET_MAPDATA_BYTE_INDEX(path, "MazePath", 3); break; //b, 4 of these
10405 case MAPDATASIDEWARPSC: GET_MAPDATA_BYTE_INDEX(sidewarpscr, "SideWarpScreen", 3); break; //b, 4 of these
10406 case MAPDATAINITD: GET_MAPDATA_VAR_INDEX32(screeninitd, "InitD", 8); break; //w, 4 of these
10407 case MAPDATASIDEWARPDMAP: GET_MAPDATA_VAR_INDEX32(sidewarpdmap, "SideWarpDMap", 3); break; //w, 4 of these
10408 case MAPDATASIDEWARPINDEX: GET_MAPDATA_VAR_BYTE(sidewarpindex, "SideWarpIndex"); break; //b
10409 case MAPDATAUNDERCOMBO: GET_MAPDATA_VAR_INT32(undercombo, "UnderCombo"); break; //w
10410 case MAPDATAUNDERCSET: GET_MAPDATA_VAR_BYTE(undercset, "UnderCSet"); break; //b
10411 case MAPDATACATCHALL: GET_MAPDATA_VAR_INT32(catchall, "Catchall"); break; //W
10412
10413 case MAPDATACSENSITIVE: GET_MAPDATA_VAR_BYTE(csensitive, "CSensitive"); break; //B
10414 case MAPDATANORESET: GET_MAPDATA_VAR_INT32(noreset, "NoReset"); break; //W
10415 case MAPDATANOCARRY: GET_MAPDATA_VAR_INT32(nocarry, "NoCarry"); break; //W
10416
4/8
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 13 times.
✓ Branch 6 taken 13 times.
✗ Branch 7 not taken.
26 case MAPDATALAYERMAP: GET_MAPDATA_LAYER_INDEX(layermap, "LayerMap", 6); break; //B, 6 OF THESE
10417
4/8
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 13 times.
✓ Branch 6 taken 13 times.
✗ Branch 7 not taken.
26 case MAPDATALAYERSCREEN: GET_MAPDATA_LAYER_INDEX(layerscreen, "LayerScreen", 6); break; //B, 6 OF THESE
10418 case MAPDATALAYEROPACITY: GET_MAPDATA_LAYER_INDEX(layeropacity, "LayerOpacity", 6); break; //B, 6 OF THESE
10419 case MAPDATATIMEDWARPTICS: GET_MAPDATA_VAR_INT32(timedwarptics, "TimedWarpTimer"); break; //W
10420 case MAPDATANEXTMAP: GET_MAPDATA_VAR_BYTE(nextmap, "NextMap"); break; //B
10421 case MAPDATANEXTSCREEN: GET_MAPDATA_VAR_BYTE(nextscr, "NextScreen"); break; //B
10422
3/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 128 times.
✗ Branch 5 not taken.
256 case MAPDATASECRETCOMBO: GET_MAPDATA_VAR_INDEX32(secretcombo, "SecretCombo", 127); break; //W, 128 OF THESE
10423
3/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 128 times.
✗ Branch 5 not taken.
256 case MAPDATASECRETCSET: GET_MAPDATA_BYTE_INDEX(secretcset, "SecretCSet", 127); break; //B, 128 OF THESE
10424
3/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 128 times.
✗ Branch 5 not taken.
256 case MAPDATASECRETFLAG: GET_MAPDATA_BYTE_INDEX(secretflag, "SecretFlags", 127); break; //B, 128 OF THESE
10425
10426 case MAPDATAVIEWX: break;//GET_MAPDATA_VAR_INT32(viewX, "ViewX"); break; //W
10427 case MAPDATASCRIPT: GET_MAPDATA_VAR_INT32(script, "Script"); break; //W
10428 case MAPDATAVIEWY: break;//GET_MAPDATA_VAR_INT32(viewY, "ViewY"); break; //W
10429 case MAPDATASCREENWIDTH: break;//GET_MAPDATA_VAR_BYTE(scrWidth, "Width"); break; //B
10430 case MAPDATASCREENHEIGHT: break;//GET_MAPDATA_VAR_BYTE(scrHeight, "Height"); break; //B
10431 case MAPDATAENTRYX: GET_MAPDATA_VAR_BYTE(entry_x, "EntryX"); break; //B
10432 case MAPDATAENTRYY: GET_MAPDATA_VAR_BYTE(entry_y, "EntryY"); break; //B
10433
3/6
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 200 times.
✓ Branch 4 taken 200 times.
✗ Branch 5 not taken.
400 case MAPDATAFFDATA: GET_MAPDATA_FFC_INDEX32(getData(), "FFCData", MAXFFCS-1); break; //W, MAXFFCS OF THESE
10434
3/6
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
16 case MAPDATAFFCSET: GET_MAPDATA_FFC_INDEX32(cset, "FFCCSet", MAXFFCS-1); break; //B, MAXFFCS
10435
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFDELAY: GET_MAPDATA_FFC_INDEX32(delay, "FFCDelay", MAXFFCS-1); break; //W, MAXFFCS
10436
3/6
✓ Branch 0 taken 392 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 392 times.
✓ Branch 4 taken 392 times.
✗ Branch 5 not taken.
784 case MAPDATAFFX: GET_MAPDATA_FFCPOS_INDEX32(x, "FFCX", MAXFFCS-1); break; //INT32, MAXFFCS OF THESE
10437
3/6
✓ Branch 0 taken 392 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 392 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 392 times.
784 case MAPDATAFFY: GET_MAPDATA_FFCPOS_INDEX32(y, "FFCY", MAXFFCS-1); break; //..
10438
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFXDELTA: GET_MAPDATA_FFCPOS_INDEX32(vx, "FFCVx", MAXFFCS-1); break; //..
10439
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFYDELTA: GET_MAPDATA_FFCPOS_INDEX32(vy, "FFCVy", MAXFFCS-1); break; //..
10440
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFXDELTA2: GET_MAPDATA_FFCPOS_INDEX32(ax, "FFCAx", MAXFFCS-1); break; //..
10441
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFYDELTA2: GET_MAPDATA_FFCPOS_INDEX32(ay, "FFCAy", MAXFFCS-1); break; //..
10442
3/6
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 91 times.
✓ Branch 4 taken 91 times.
✗ Branch 5 not taken.
182 case MAPDATAFFFLAGS: GET_MAPDATA_FFC_INDEX32(flags, "FFCFlags", MAXFFCS-1); break; //INT16, MAXFFCS OF THESE
10443 case MAPDATASIDEWARPID:
10444 {
10445 int32_t indx = ri->d[rINDEX] / 10000;
10446 if (mapscr *m = GetMapscr(ri->mapsref))
10447 {
10448 ret = (((m->flags2 >> indx) & 1)
10449 ? (m->sidewarpindex >> (2*indx)) & 3 //Return which warp is set
10450 : -1 //Returns -1 if no warp is set
10451 )*10000;
10452 }
10453 else
10454 {
10455 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","SideWarpID");
10456 ret = -10000;
10457 }
10458 break;
10459 }
10460 //Number of ffcs that are in use (have valid data
10461 case MAPDATANUMFF:
10462 {
10463 32 uint32_t indx = ri->d[rINDEX] / 10000;
10464
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
32 if (!indx || indx > MAXFFCS)
10465 {
10466 Z_scripterrlog("Invalid Index passed to mapdata->NumFFCs[%d].\n Valid indices are 1 through %d.\n", indx, MAXFFCS);
10467 ret = 0;
10468 }
10469
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 else if (mapscr *m = GetMapscr(ri->mapsref))
10470 {
10471 32 --indx;
10472 32 ret = (m->ffcs[indx].getData() != 0) ? 10000 : 0;
10473 32 }
10474 else
10475 {
10476 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","NumFFCs[]");
10477 ret = 0;
10478 }
10479 32 break;
10480 }
10481
10482 case MAPDATATILEWARPOVFLAGS:
10483 {
10484 int32_t indx = ri->d[rINDEX] / 10000;
10485 if ( ((unsigned)indx) > 3 )
10486 {
10487 Z_scripterrlog("Invalid index passed to TileWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
10488 ret = 0;
10489 }
10490 else if (mapscr *m = GetMapscr(ri->mapsref))
10491 {
10492 ret = (m->tilewarpoverlayflags & (1<<indx))?10000:0;
10493 }
10494 else
10495 {
10496 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","NumFFCs[]");
10497 ret = 0;
10498 }
10499 break;
10500 }
10501
10502 case MAPDATASIDEWARPOVFLAGS:
10503 {
10504 int32_t indx = ri->d[rINDEX] / 10000;
10505 if ( ((unsigned)indx) > 3 )
10506 {
10507 Z_scripterrlog("Invalid index passed to SideWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
10508 ret = 0;
10509 }
10510 else if (mapscr *m = GetMapscr(ri->mapsref))
10511 {
10512 ret = (m->sidewarpoverlayflags & (1<<indx))?10000:0;
10513 }
10514 else
10515 {
10516 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","NumFFCs[]");
10517 ret = 0;
10518 }
10519 break;
10520 }
10521
10522 case MAPDATATWARPRETSQR:
10523 {
10524 int32_t indx = ri->d[rINDEX] / 10000;
10525 if ( ((unsigned)indx) > 3)
10526 {
10527 ret = -10000;
10528 Z_scripterrlog("Invalid Array Index passed to mapdata->TileWarpReturnSquare[]: %d\n", indx);
10529
10530 }
10531 else if (mapscr *m = GetMapscr(ri->mapsref))
10532 {
10533 ret = ((m->warpreturnc>>(indx*2))&3) * 10000;
10534 }
10535 else
10536 {
10537 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str");
10538 ret = -10000;
10539 }
10540 break;
10541 }
10542
10543 case MAPDATASWARPRETSQR:
10544 {
10545 int32_t indx = ri->d[rINDEX] / 10000;
10546 if ( ((unsigned)indx) > 3)
10547 {
10548 ret = -10000;
10549 Z_scripterrlog("Invalid Array Index passed to mapdata->TileWarpReturnSquare[]: %d\n", indx);
10550
10551 }
10552 else if (mapscr *m = GetMapscr(ri->mapsref))
10553 {
10554 ret = ((m->warpreturnc>>(8+(indx*2)))&3) * 10000;
10555 }
10556 else
10557 {
10558 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str");
10559 ret = -10000;
10560 }
10561 break;
10562 }
10563
10564 case MAPDATAFFWIDTH:
10565 {
10566
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (mapscr *m = GetMapscr(ri->mapsref))
10567 {
10568 8 int32_t indx = (ri->d[rINDEX] / 10000)-1;
10569
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if ( indx < 0 || indx > MAXFFCS-1 )
10570 {
10571 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCTileWidth[]: %d\n", indx+1);
10572 ret = -10000;
10573 break;
10574 }
10575 8 ret=(m->ffTileWidth(indx))*10000;
10576 8 }
10577 else
10578 {
10579 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCTileWidth[]");
10580 ret = -10000;
10581 }
10582 8 break;
10583 }
10584
10585 case MAPDATAFFHEIGHT:
10586 {
10587
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (mapscr *m = GetMapscr(ri->mapsref))
10588 {
10589 8 int32_t indx = (ri->d[rINDEX] / 10000)-1;
10590
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if ( indx < 0 || indx > MAXFFCS-1 )
10591 {
10592 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCTileHeight[]: %d\n", indx+1);
10593 ret = -10000;
10594 break;
10595 }
10596 8 ret=(m->ffTileHeight(indx))*10000;
10597 8 }
10598 else
10599 {
10600 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCTileHeight[]");
10601 ret = -10000;
10602 }
10603 8 break;
10604
10605 }
10606
10607 case MAPDATAFFEFFECTWIDTH:
10608 {
10609
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (mapscr *m = GetMapscr(ri->mapsref))
10610 {
10611 5 int32_t indx = (ri->d[rINDEX] / 10000)-1;
10612
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if ( indx < 0 || indx > MAXFFCS-1 )
10613 {
10614 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCEffectWidth[]: %d\n", indx+1);
10615 ret = -10000;
10616 break;
10617 }
10618 5 ret=(m->ffEffectWidth(indx))*10000;
10619 5 }
10620 else
10621 {
10622 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCEffectWidth[]");
10623 ret = -10000;
10624 }
10625 5 break;
10626 }
10627
10628 case MAPDATAFFEFFECTHEIGHT:
10629 {
10630
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (mapscr *m = GetMapscr(ri->mapsref))
10631 {
10632 5 int32_t indx = (ri->d[rINDEX] / 10000)-1;
10633
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if ( indx < 0 || indx > MAXFFCS-1 )
10634 {
10635 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCEffectHeight[]: %d\n", indx+1);
10636 ret = -10000;
10637 break;
10638 }
10639 5 ret=(m->ffEffectHeight(indx))*10000;
10640 5 }
10641 else
10642 {
10643 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCEffectHeight[]");
10644 ret = -10000;
10645 }
10646 5 break;
10647 }
10648
10649
10650 case MAPDATAFFLINK: GET_MAPDATA_FFC_INDEX32(link, "FFCLink", MAXFFCS-1); break; //B, MAXFFCS OF THESE
10651
3/6
✓ Branch 0 taken 32773 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32773 times.
✓ Branch 4 taken 32773 times.
✗ Branch 5 not taken.
65546 case MAPDATAFFSCRIPT: GET_MAPDATA_FFC_INDEX32(script, "FFCScript", MAXFFCS-1); break; //W, MAXFFCS OF THESE
10652
10653 case MAPDATAINTID: //Same form as SetScreenD()
10654 //SetFFCInitD(ffindex, d, value)
10655 {
10656
1/2
✓ Branch 0 taken 1800 times.
✗ Branch 1 not taken.
1800 if (mapscr *m = GetMapscr(ri->mapsref))
10657 {
10658 1800 int32_t ffid = (ri->d[rINDEX]/10000) -1;
10659 1800 int32_t indx = ri->d[rINDEX2]/10000;
10660
10661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1800 times.
1800 if ( (unsigned)ffid > MAXFFCS-1 )
10662 {
10663 Z_scripterrlog("Invalid FFC id passed to mapdata->FFCInitD[]: %d",ffid);
10664 ret = -10000;
10665 }
10666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1800 times.
1800 else if ( (unsigned)indx > 7 )
10667 {
10668 Z_scripterrlog("Invalid InitD[] index passed to mapdata->FFCInitD[]: %d",indx);
10669 ret = -10000;
10670 }
10671 else
10672 {
10673 1800 ret = (m->ffcs[ffid].initd[indx]);
10674 }
10675
10676 //int32_t ffindex = ri->d[rINDEX]/10000;
10677 //int32_t d = ri->d[rINDEX2]/10000;
10678 //int32_t v = (value/10000);
10679 1800 }
10680 else
10681 {
10682 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","GetFFCInitD()");
10683 ret = -10000;
10684 }
10685 1800 break;
10686 }
10687
10688
10689
10690 //initd //INT32 , 32 OF THESE, EACH WITH 10 INDICES.
10691
10692 case MAPDATAINITA:
10693 //same form as SetScreenD
10694 {
10695 if (mapscr *m = GetMapscr(ri->mapsref))
10696 {
10697 //int32_t ffindex = ri->d[rINDEX]/10000;
10698 //int32_t d = ri->d[rINDEX2]/10000;
10699 //int32_t v = (value/10000);
10700
10701 int32_t ffid = (ri->d[rINDEX]/10000) -1;
10702 int32_t indx = ri->d[rINDEX2]/10000;
10703
10704 if ( (unsigned)ffid > MAXFFCS-1 )
10705 {
10706 Z_scripterrlog("Invalid FFC id passed to mapdata->FFCInitD[]: %d",ffid);
10707 ret = -10000;
10708 }
10709 else if ( (unsigned)indx > 1 )
10710 {
10711 Z_scripterrlog("Invalid InitD[] index passed to mapdata->FFCInitD[]: %d",indx);
10712 ret = -10000;
10713 }
10714 else
10715 {
10716 ret = (m->ffcs[ffid].inita[indx]);
10717 }
10718 }
10719 else
10720 {
10721 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","GetFFCInitD()");
10722 ret = -10000;
10723 }
10724 break;
10725 }
10726
10727 //inita //INT32, 32 OF THESE, EACH WITH 2
10728
10729 case MAPDATAFFINITIALISED:
10730 {
10731 int32_t indx = ri->d[rINDEX] / 10000;
10732 if (indx < 0 || indx > MAXFFCS-1)
10733 {
10734 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", "FFCRunning", indx);
10735 ret = -10000;
10736 }
10737 else
10738 {
10739 if (mapscr *m = GetMapscr(ri->mapsref))
10740 {
10741 ret = get_script_engine_data(ScriptType::FFC, indx).initialized ? 10000 : 0;
10742 }
10743 else
10744 {
10745 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n", "FFCRunning");
10746 ret = -10000;
10747 }
10748 }
10749 }
10750 break;
10751
10752 case MAPDATASCRIPTENTRY: GET_MAPDATA_VAR_INT32(script_entry, "ScriptEntry"); break; //W
10753 case MAPDATASCRIPTOCCUPANCY: GET_MAPDATA_VAR_INT32(script_occupancy, "ScriptOccupancy"); break;//W
10754 case MAPDATASCRIPTEXIT: GET_MAPDATA_VAR_INT32(script_exit, "ExitScript"); break; //W
10755 case MAPDATAOCEANSFX: GET_MAPDATA_VAR_BYTE(oceansfx, "OceanSFX"); break; //B
10756 case MAPDATABOSSSFX: GET_MAPDATA_VAR_BYTE(bosssfx, "BossSFX"); break; //B
10757 case MAPDATASECRETSFX: GET_MAPDATA_VAR_BYTE(secretsfx, "SecretSFX"); break; //B
10758 case MAPDATAHOLDUPSFX: GET_MAPDATA_VAR_BYTE(holdupsfx, "ItemSFX"); break; //B
10759 case MAPDATASCREENMIDI:
10760 {
10761 if (mapscr *m = GetMapscr(ri->mapsref))
10762 {
10763 ret = ((m->screen_midi+(MIDIOFFSET_MAPSCR-MIDIOFFSET_ZSCRIPT)) *10000);
10764 }
10765 else
10766 {
10767 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","MIDI");
10768 ret = -10000;
10769 }
10770 break;
10771 }
10772 case MAPDATALENSLAYER: GET_MAPDATA_VAR_BYTE(lens_layer, "LensLayer"); break; //B, OLD QUESTS ONLY?
10773 case MAPDATAMAP:
10774 {
10775
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if (mapscr *m = GetMapscr(ri->mapsref))
10776 {
10777 18 ret = getMap(ri->mapsref) * 10000;
10778 18 }
10779 else
10780 {
10781 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Map");
10782 ret = -10000;
10783 }
10784 18 break;
10785 }
10786 case MAPDATASCREEN:
10787 {
10788
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if (mapscr *m = GetMapscr(ri->mapsref))
10789 {
10790 42 ret = getScreen(ri->mapsref) * 10000;
10791 42 }
10792 else
10793 {
10794 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Screen");
10795 ret = -10000;
10796 }
10797 42 break;
10798 }
10799
10800 case MAPDATAFLAGS:
10801 {
10802
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(mapscr *m = GetMapscr(ri->mapsref))
10803 {
10804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if ( get_qr(qr_OLDMAPDATAFLAGS) )
10805 {
10806 ret = get_screenflags(m,vbound(ri->d[rINDEX] / 10000,0,9));
10807 }
10808 else
10809 {
10810 6 int32_t flagid = (ri->d[rINDEX])/10000;
10811 //bool valtrue = ( value ? 10000 : 0);
10812
1/11
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
6 switch(flagid)
10813 {
10814 case 0: ret = (m->flags * 10000); break;
10815 case 1: ret = (m->flags2 * 10000); break;
10816 case 2: ret = (m->flags3 * 10000); break;
10817 case 3: ret = (m->flags4 * 10000); break;
10818 case 4: ret = (m->flags5 * 10000); break;
10819 case 5: ret = (m->flags6 * 10000); break;
10820 6 case 6: ret = (m->flags7 * 10000); break;
10821 case 7: ret = (m->flags8 * 10000); break;
10822 case 8: ret = (m->flags9 * 10000); break;
10823 case 9: ret = (m->flags10 * 10000); break;
10824 default:
10825 {
10826 Z_scripterrlog("Invalid index passed to mapdata->flags[]: %d\n", flagid);
10827 ret = -10000;
10828 break;
10829
10830 }
10831 }
10832 }
10833 6 }
10834 else
10835 {
10836 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Flags[]");
10837 ret = -10000;
10838 }
10839
10840 6 break;
10841 //GET_MAPDATA_BYTE_INDEX //B, 11 OF THESE, flags, flags2-flags10
10842 }
10843
10844 case MAPDATAMISCD:
10845 {
10846 int32_t indx = (ri->d[rINDEX])/10000;
10847 int32_t mi = get_mi(ri->mapsref);
10848 if(unsigned(mi) >= MAX_MI)
10849 {
10850 ret = 0;
10851 break;
10852 }
10853 if( ((unsigned)indx) > 7 )
10854 {
10855 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", indx);
10856 ret = -10000;
10857 }
10858 else if (mapscr *m = GetMapscr(ri->mapsref))
10859 {
10860 ret = (game->screen_d[mi][indx]) * 10000;
10861 }
10862 else
10863 {
10864 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","D[]");
10865 ret = -10000;
10866 }
10867 break;
10868 }
10869
10870 case MAPDATACOMBODD:
10871 {
10872
1/2
✓ Branch 0 taken 4767952 times.
✗ Branch 1 not taken.
4767952 if (mapscr *m = GetMapscr(ri->mapsref))
10873 {
10874 4767952 int32_t pos = ri->d[rINDEX] / 10000;
10875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4767952 times.
4767952 if(BC::checkComboPos(pos, "mapdata->ComboD[pos]") != SH::_NoError)
10876 {
10877 ret = -10000;
10878 }
10879 else
10880 {
10881 4767952 ret = m->data[pos] * 10000;
10882 }
10883 4767952 }
10884 else
10885 {
10886 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboD[]",ri->mapsref);
10887 ret = -10000;
10888 }
10889 4767952 break;
10890 //GET_SCREENDATA_COMBO_VAR(data, "mapdata->ComboD") break;
10891 }
10892
10893 case MAPDATACOMBOCD:
10894 {
10895
1/2
✓ Branch 0 taken 4654485 times.
✗ Branch 1 not taken.
4654485 if (mapscr *m = GetMapscr(ri->mapsref))
10896 {
10897 //int32_t ffindex = ri->d[rINDEX]/10000;
10898 //int32_t d = ri->d[rINDEX2]/10000;
10899 //int32_t v = (value/10000);
10900 4654485 int32_t pos = ri->d[rINDEX] / 10000;
10901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4654485 times.
4654485 if(BC::checkComboPos(pos, "mapdata->ComboC[pos]") != SH::_NoError)
10902 {
10903 ret = -10000;
10904 }
10905 else
10906 {
10907 4654485 ret = m->cset[pos] * 10000;
10908 }
10909 4654485 }
10910 else
10911 {
10912 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboC[]",ri->mapsref);
10913 ret = -10000;
10914 }
10915 4654485 break;
10916 }
10917 //GET_SCREENDATA_COMBO_VAR(cset, "mapdata->ComboC") break;
10918
10919 case MAPDATACOMBOFD:
10920 {
10921
1/2
✓ Branch 0 taken 5945377 times.
✗ Branch 1 not taken.
5945377 if (mapscr *m = GetMapscr(ri->mapsref))
10922 {
10923 //int32_t ffindex = ri->d[rINDEX]/10000;
10924 //int32_t d = ri->d[rINDEX2]/10000;
10925 //int32_t v = (value/10000);
10926 5945377 int32_t pos = ri->d[rINDEX] / 10000;
10927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5945377 times.
5945377 if(BC::checkComboPos(pos, "mapdata->ComboF[pos]") != SH::_NoError)
10928 {
10929 ret = -10000;
10930 }
10931 else
10932 {
10933 5945377 ret = m->sflag[pos] * 10000;
10934 }
10935 5945377 }
10936 else
10937 {
10938 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboF[]",ri->mapsref);
10939 ret = -10000;
10940 }
10941 5945377 break;
10942 }
10943 //GET_SCREENDATA_COMBO_VAR(sflag, "mapdata->ComboF") break;
10944
10945
10946
10947 case MAPDATACOMBOTD:
10948 {
10949
1/2
✓ Branch 0 taken 2540907 times.
✗ Branch 1 not taken.
2540907 if (mapscr *m = GetMapscr(ri->mapsref))
10950 {
10951 //int32_t ffindex = ri->d[rINDEX]/10000;
10952 //int32_t d = ri->d[rINDEX2]/10000;
10953 //int32_t v = (value/10000);
10954 2540907 int32_t pos = ri->d[rINDEX] / 10000;
10955
1/2
✓ Branch 0 taken 2540907 times.
✗ Branch 1 not taken.
2540907 if(BC::checkComboPos(pos, "mapdata->ComboT[pos]") != SH::_NoError)
10956 {
10957 ret = -10000;
10958
10959 }
10960 else
10961 {
10962 2540907 ret = combobuf[m->data[pos]].type * 10000;
10963 }
10964 2540907 }
10965 else
10966 {
10967 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboT[]",ri->mapsref);
10968 ret = -10000;
10969 }
10970 2540907 break;
10971 }
10972 //GET_MAPDATA_COMBO_VAR_BUF(type, "mapdata->ComboT") break;
10973
10974 case MAPDATACOMBOID:
10975 {
10976
1/2
✓ Branch 0 taken 345816 times.
✗ Branch 1 not taken.
345816 if (mapscr *m = GetMapscr(ri->mapsref))
10977 {
10978 //int32_t ffindex = ri->d[rINDEX]/10000;
10979 //int32_t d = ri->d[rINDEX2]/10000;
10980 //int32_t v = (value/10000);
10981 345816 int32_t pos = ri->d[rINDEX] / 10000;
10982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 345816 times.
345816 if(BC::checkComboPos(pos, "mapdata->ComboI[pos]") != SH::_NoError)
10983 {
10984 ret = -10000;
10985 }
10986 else
10987 {
10988 345816 ret = combobuf[m->data[pos]].flag * 10000;
10989 }
10990 345816 }
10991 else
10992 {
10993 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboI[]",ri->mapsref);
10994 ret = -10000;
10995 }
10996 345816 break;
10997 //GET_SCREENDATA_COMBO_VAR(data, "mapdata->ComboD") break;
10998 }
10999 //GET_MAPDATA_COMBO_VAR_BUF(flag, "mapdata->ComboI") break;
11000
11001 case MAPDATACOMBOSD:
11002 {
11003
1/2
✓ Branch 0 taken 85947 times.
✗ Branch 1 not taken.
85947 if (mapscr *m = GetMapscr(ri->mapsref))
11004 {
11005 //int32_t ffindex = ri->d[rINDEX]/10000;
11006 //int32_t d = ri->d[rINDEX2]/10000;
11007 //int32_t v = (value/10000);
11008 85947 int32_t pos = ri->d[rINDEX] / 10000;
11009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85947 times.
85947 if(BC::checkComboPos(pos, "mapdata->ComboS[pos]") != SH::_NoError)
11010 {
11011 ret = -10000;
11012 }
11013 else
11014 {
11015 85947 ret = (combobuf[m->data[pos]].walk & 0xF) * 10000;
11016 }
11017 85947 }
11018 else
11019 {
11020 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboS[]", ri->mapsref);
11021 ret = -10000;
11022 }
11023 85947 break;
11024 }
11025
11026 case MAPDATACOMBOED:
11027 {
11028 if (mapscr *m = GetMapscr(ri->mapsref))
11029 {
11030 //int32_t ffindex = ri->d[rINDEX]/10000;
11031 //int32_t d = ri->d[rINDEX2]/10000;
11032 //int32_t v = (value/10000);
11033 int32_t pos = ri->d[rINDEX] / 10000;
11034 if(BC::checkComboPos(pos, "mapdata->ComboE[pos]") != SH::_NoError)
11035 {
11036 ret = -10000;
11037 }
11038 else
11039 {
11040 ret = ((combobuf[m->data[pos]].walk & 0xF0)>>4) * 10000;
11041 }
11042 }
11043 else
11044 {
11045 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboE[]", ri->mapsref);
11046 ret = -10000;
11047 }
11048 break;
11049 }
11050
11051 case MAPDATASCREENSTATED:
11052 {
11053
1/2
✓ Branch 0 taken 45056 times.
✗ Branch 1 not taken.
45056 if (mapscr *m = GetMapscr(ri->mapsref))
11054 {
11055 45056 int32_t mi = get_mi(ri->mapsref);
11056
1/2
✓ Branch 0 taken 45056 times.
✗ Branch 1 not taken.
45056 if(mi<0) {ret = 0;break;}
11057 45056 ret=((game->maps[mi]>>((ri->d[rINDEX]/10000)))&1)?10000:0;
11058 45056 }
11059 else
11060 {
11061 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","State[]", ri->mapsref);
11062 ret = 0;
11063 }
11064 45056 break;
11065 }
11066 case MAPDATAEXSTATED:
11067 {
11068 if (mapscr *m = GetMapscr(ri->mapsref))
11069 {
11070 int32_t mi = get_mi(ri->mapsref);
11071 if(mi<0) {ret = 0;break;}
11072 ret=((game->xstates[mi]>>((ri->d[rINDEX]/10000)))&1)?10000:0;
11073 }
11074 else
11075 {
11076 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","State[]", ri->mapsref);
11077 ret = 0;
11078 }
11079 break;
11080 }
11081 case MAPDATALENSSHOWS:
11082 {
11083 ret = 0;
11084 int ind = ri->d[rINDEX]/10000;
11085 if(ind < 0 || ind > 6)
11086 Z_scripterrlog("Bad index mapdata->LensShows[%d]\n",ind);
11087 else if(mapscr *m = GetMapscr(ri->mapsref))
11088 ret = (m->lens_show & (1<<ind)) ? 10000 : 0;
11089 else Z_scripterrlog("mapdata->LensShows[] pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
11090 break;
11091 }
11092 case MAPDATALENSHIDES:
11093 {
11094 ret = 0;
11095 int ind = ri->d[rINDEX]/10000;
11096 if(ind < 0 || ind > 6)
11097 Z_scripterrlog("Bad index mapdata->LensHides[%d]\n",ind);
11098 else if(mapscr *m = GetMapscr(ri->mapsref))
11099 ret = (m->lens_hide & (1<<ind)) ? 10000 : 0;
11100 else Z_scripterrlog("mapdata->LensHides[] pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
11101 break;
11102 }
11103 case MAPDATASCRDATASIZE:
11104 {
11105 ret = -10000;
11106 if(mapscr *m = GetMapscr(ri->mapsref))
11107 {
11108 auto mi = get_total_mi(ri->mapsref);
11109 if(mi < 0) break;
11110 ret = 10000*game->scriptDataSize(mi);
11111 }
11112 else Z_scripterrlog("mapdata->DataSize pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
11113 break;
11114 }
11115 case MAPDATASCRDATA:
11116 {
11117 ret = -10000;
11118 if(mapscr *m = GetMapscr(ri->mapsref))
11119 {
11120 auto mi = get_total_mi(ri->mapsref);
11121 if(mi < 0) break;
11122 size_t indx = ri->d[rINDEX]/10000;
11123 if(indx >= game->scriptDataSize(mi))
11124 Z_scripterrlog("Invalid index passed to mapdata->Data[]: %d\n", indx);
11125 else ret = game->screen_data[mi][indx];
11126 }
11127 else Z_scripterrlog("mapdata->Data[] pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
11128 break;
11129 }
11130 case MAPDATASCREENFLAGSD:
11131 {
11132 if(mapscr *m = GetMapscr(ri->mapsref))
11133 {
11134 ret = get_screenflags(m,vbound(ri->d[rINDEX] / 10000,0,9));
11135 }
11136 else
11137 {
11138 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","SFlags[]", ri->mapsref);
11139 ret = -10000;
11140 }
11141 break;
11142 }
11143
11144 case MAPDATASCREENEFLAGSD:
11145 {
11146 if(mapscr *m = GetMapscr(ri->mapsref))
11147 {
11148 ret = get_screeneflags(m,vbound(ri->d[rINDEX] / 10000,0,2));
11149 }
11150 else
11151 {
11152 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","EFlags[]", ri->mapsref);
11153 ret = -10000;
11154 }
11155 break;
11156 }
11157
11158 ///----------------------------------------------------------------------------------------------------//
11159 //shopdata sd-> variables
11160
11161 case SHOPDATATYPE:
11162 {
11163 int32_t ref = ri->shopsref;
11164 if ( ref > NUMINFOSHOPS || ref < 0 ) ret = 0;
11165 else ret = ( ( ref <= NUMSHOPS ) ? 10000 : 20000 );
11166 break;
11167 }
11168 case SHOPDATAITEM:
11169 {
11170
11171 int32_t ref = ri->shopsref;
11172 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
11173 int32_t indx = ri->d[rINDEX] / 10000;
11174 if ( indx < 0 || indx > 2 )
11175 {
11176 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "Item");
11177 ret = -10000;
11178 }
11179 else
11180 {
11181 if ( isInfo )
11182 {
11183 Z_scripterrlog("Attempted to load an 'item' from an infoshop, using shop ID: %d\n", ri->shopsref);
11184 ret = -10000;
11185 }
11186 else
11187 {
11188 ret = ((int32_t)(QMisc.shop[ref].item[indx]) * 10000);
11189 }
11190 }
11191 break;
11192 }
11193
11194
11195 // GET_SHOPDATA_VAR_INDEX(item, "Item", 2); break;
11196 case SHOPDATAHASITEM:
11197 {
11198
11199 int32_t ref = ri->shopsref;
11200 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
11201 int32_t indx = ri->d[rINDEX] / 10000;
11202 if ( indx < 0 || indx > 2 )
11203 {
11204 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "HasItem");
11205 ret = -10000;
11206 }
11207 else
11208 {
11209 if ( isInfo )
11210 {
11211 Z_scripterrlog("Attempted to load 'hasitem' from an infoshop, using shop ID: %d\n", ri->shopsref);
11212 ret = -10000;
11213 }
11214 else
11215 {
11216 ret = ((int32_t)(QMisc.shop[ref].hasitem[indx]) * 10000);
11217 }
11218 }
11219 break;
11220 }
11221
11222
11223 //GET_SHOPDATA_VAR_INDEX(hasitem, "HasItem", 2); break;
11224 case SHOPDATAPRICE:
11225 {
11226
11227 int32_t ref = ri->shopsref;
11228 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
11229 int32_t indx = ri->d[rINDEX] / 10000;
11230 if ( indx < 0 || indx > 2 )
11231 {
11232 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "Price");
11233 ret = -10000;
11234 }
11235 else
11236 {
11237 if ( isInfo )
11238 {
11239 ret = ((int32_t)(QMisc.info[ref - NUMSHOPS].price[indx]) * 10000);
11240 }
11241 else
11242 {
11243 ret = ((int32_t)(QMisc.shop[ref].price[indx]) * 10000);
11244 }
11245 }
11246 break;
11247 }
11248
11249
11250 //GET_SHOPDATA_VAR_INDEX(price, "Price", 2); break;
11251 //Pay for info
11252 case SHOPDATASTRING:
11253 {
11254 int32_t ref = ri->shopsref;
11255 if (ref < NUMSHOPS || ref > NUMINFOSHOPS)
11256 {
11257 Z_scripterrlog("Invalid shop pointer passed to shopdata->String[]: %d\n", ref);
11258 ret = -10000;
11259 }
11260 else
11261 {
11262 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
11263 int32_t indx = ri->d[rINDEX] / 10000;
11264 if ( indx < 0 || indx > 2 )
11265 {
11266 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "String");
11267 }
11268 else
11269 {
11270 if ( isInfo )
11271 {
11272 ret = ((int32_t)(QMisc.info[ref - NUMSHOPS].str[indx]) * 10000);
11273 }
11274 else
11275 {
11276 ret = ((int32_t)(QMisc.shop[ref].str[indx]) * 10000);
11277 }
11278 }
11279
11280
11281 }
11282
11283 //GET_SHOPDATA_VAR_INDEX(str, String, 2); break;
11284 break;
11285 }
11286
11287
11288 ///----------------------------------------------------------------------------------------------------//
11289 //dmapdata dmd-> variables
11290
11291 //getter
11292 701 case DMAPDATAID: ret = ri->dmapsref*10000; break; //read-only, equal to CurrentDMap
11293
11294 case DMAPDATAMAP: //byte
11295 {
11296 213 ret = ((byte)DMaps[ri->dmapsref].map + 1) * 10000; break;
11297 }
11298 case DMAPDATALEVEL: //word
11299 {
11300 ret = ((word)DMaps[ri->dmapsref].level) * 10000; break;
11301 }
11302 case DMAPDATAOFFSET: //char
11303 {
11304 6 ret = ((char)DMaps[ri->dmapsref].xoff) * 10000; break;
11305 }
11306 case DMAPDATACOMPASS: //byte
11307 {
11308 ret = ((byte)DMaps[ri->dmapsref].compass) * 10000; break;
11309 }
11310 case DMAPDATAPALETTE: //word
11311 {
11312 192 ret = ((word)DMaps[ri->dmapsref].color) * 10000; break;
11313 }
11314 case DMAPSCRIPT: //word
11315 {
11316 19 ret = (DMaps[ri->dmapsref].script) * 10000; break;
11317 }
11318 case DMAPDATAMIDI: //byte
11319 {
11320 ret = (DMaps[ri->dmapsref].midi-MIDIOFFSET_DMAP) * 10000; break;
11321 }
11322 case DMAPDATACONTINUE: //byte
11323 {
11324 ret = ((byte)DMaps[ri->dmapsref].cont) * 10000; break;
11325 }
11326 case DMAPDATATYPE: //byte
11327 {
11328 1124 ret = ((byte)DMaps[ri->dmapsref].type&dmfTYPE) * 10000; break;
11329 }
11330 case DMAPDATASIDEVIEW: //byte
11331 {
11332 734895 ret = ((DMaps[ri->dmapsref].sideview) ? 10000 : 0); break;
11333 }
11334 case DMAPDATAGRID: //byte[8] --array
11335 {
11336 43092 int32_t indx = ri->d[rINDEX] / 10000;
11337
2/4
✓ Branch 0 taken 43092 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 43092 times.
43092 if ( indx < 0 || indx > 7 )
11338 {
11339 Z_scripterrlog("Invalid index supplied to dmapdata->Grid[]: %d\n", indx);
11340 ret = -10000;
11341 break;
11342 }
11343 else
11344 {
11345 43092 ret = ((byte)DMaps[ri->dmapsref].grid[indx]) * 10000; break;
11346 }
11347 }
11348 case DMAPINITD: //byte[8] --array
11349 {
11350 45 int32_t indx = ri->d[rINDEX] / 10000;
11351
2/4
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
45 if ( indx < 0 || indx > 7 )
11352 {
11353 Z_scripterrlog("Invalid index supplied to dmapdata->InitD[]: %d\n", indx);
11354 ret = -10000;
11355 break;
11356 }
11357 else
11358 {
11359 45 ret = DMaps[ri->dmapsref].initD[indx]; break;
11360 }
11361 }
11362 case DMAPDATAMINIMAPTILE: //word - two of these, so let's do MinimapTile[2]
11363 {
11364 1402 int32_t indx = ri->d[rINDEX] / 10000;
11365
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 718 times.
✓ Branch 2 taken 684 times.
1402 switch(indx)
11366 {
11367 718 case 0: { ret = ((word)DMaps[ri->dmapsref].minimap_1_tile) * 10000; break; }
11368 684 case 1: { ret = ((word)DMaps[ri->dmapsref].minimap_2_tile) * 10000; break; }
11369 default:
11370 {
11371 Z_scripterrlog("Invalid index supplied to dmapdata->MiniMapTile[]: %d\n", indx);
11372 ret = -10000;
11373 break;
11374 }
11375 }
11376 1402 break;
11377 }
11378 case DMAPDATAMINIMAPCSET: //byte - two of these, so let's do MinimapCSet[2]
11379 {
11380 17 int32_t indx = ri->d[rINDEX] / 10000;
11381
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
17 switch(indx)
11382 {
11383 17 case 0: { ret = ((byte)DMaps[ri->dmapsref].minimap_1_cset) * 10000; break; }
11384 case 1: { ret = ((byte)DMaps[ri->dmapsref].minimap_2_cset) * 10000; break; }
11385 default:
11386 {
11387 Z_scripterrlog("Invalid index supplied to dmapdata->MiniMapCSet[]: %d\n", indx);
11388 ret = -10000;
11389 break;
11390 }
11391 }
11392 17 break;
11393 }
11394 case DMAPDATALARGEMAPTILE: //word -- two of these, so let's to LargemapTile[2]
11395 {
11396 int32_t indx = ri->d[rINDEX] / 10000;
11397 switch(indx)
11398 {
11399 case 0: { ret = ((word)DMaps[ri->dmapsref].largemap_1_tile) * 10000; break; }
11400 case 1: { ret = ((word)DMaps[ri->dmapsref].largemap_2_tile) * 10000; break; }
11401 default:
11402 {
11403 Z_scripterrlog("Invalid index supplied to dmapdata->MapTile[]: %d\n", indx);
11404 ret = -10000;
11405 break;
11406 }
11407 }
11408 break;
11409 }
11410 case DMAPDATALARGEMAPCSET: //word -- two of these, so let's to LargemaCSet[2]
11411 {
11412 int32_t indx = ri->d[rINDEX] / 10000;
11413 switch(indx)
11414 {
11415 case 0: { ret = ((byte)DMaps[ri->dmapsref].largemap_1_cset) * 10000; break; }
11416 case 1: { ret = ((byte)DMaps[ri->dmapsref].largemap_2_cset) * 10000; break; }
11417 default:
11418 {
11419 Z_scripterrlog("Invalid index supplied to dmapdata->MapCSet[]: %d\n", indx);
11420 ret = -10000;
11421 break;
11422 }
11423 }
11424 break;
11425 }
11426 case DMAPDATAMUISCTRACK: //byte
11427 {
11428 ret = ((byte)DMaps[ri->dmapsref].tmusictrack) * 10000; break;
11429 }
11430 case DMAPDATASUBSCRA:
11431 {
11432 ret = ((byte)DMaps[ri->dmapsref].active_subscreen) * 10000; break;
11433 }
11434 case DMAPDATASUBSCRP:
11435 {
11436 ret = ((byte)DMaps[ri->dmapsref].passive_subscreen) * 10000; break;
11437 }
11438 case DMAPDATASUBSCRO:
11439 {
11440 ret = ((byte)DMaps[ri->dmapsref].overlay_subscreen) * 10000; break;
11441 }
11442 case DMAPDATADISABLEDITEMS: //byte[MAXITEMS]
11443 {
11444 int32_t indx = ri->d[rINDEX] / 10000;
11445 if ( indx < 0 || indx > (MAXITEMS-1) )
11446 {
11447 Z_scripterrlog("Invalid index supplied to dmapdata->Grid[]: %d\n", indx);
11448 ret = -10000;
11449 break;
11450 }
11451 else
11452 {
11453 ret = ((byte)DMaps[ri->dmapsref].disableditems[indx]) * 10000; break;
11454 }
11455 }
11456 case DMAPDATAFLAGARR: //int32_t
11457 {
11458 6 int32_t indx = ri->d[rINDEX] / 10000;
11459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if ( ((unsigned)indx) > 31 )
11460 {
11461 Z_scripterrlog("Invalid index supplied to dmapdata->Flags[]: %d\n", indx);
11462 ret = -10000;
11463 break;
11464 }
11465 6 ret = ((DMaps[ri->dmapsref].flags&(1<<indx)) ? 10000:0);
11466 6 break;
11467 }
11468 case DMAPDATAFLAGS: //int32_t
11469 {
11470 ret = (DMaps[ri->dmapsref].flags) * 10000; break;
11471 }
11472 case DMAPDATAMIRRDMAP:
11473 {
11474 ret = (DMaps[ri->dmapsref].mirrorDMap) * 10000; break;
11475 }
11476 case DMAPDATALOOPSTART:
11477 {
11478 ret = (DMaps[ri->dmapsref].tmusic_loop_start); break;
11479 }
11480 case DMAPDATALOOPEND:
11481 {
11482 ret = (DMaps[ri->dmapsref].tmusic_loop_end); break;
11483 }
11484 case DMAPDATAXFADEIN:
11485 {
11486 ret = (DMaps[ri->dmapsref].tmusic_xfade_in * 10000); break;
11487 }
11488 case DMAPDATAXFADEOUT:
11489 {
11490 ret = (DMaps[ri->dmapsref].tmusic_xfade_out * 10000); break;
11491 }
11492 case DMAPDATAINTROSTRINGID:
11493 {
11494 ret = (DMaps[ri->dmapsref].intro_string_id * 10000); break;
11495 }
11496 case MUSICUPDATECOND:
11497 {
11498 ret = ((byte)FFCore.music_update_cond) * 10000; break;
11499 }
11500 case MUSICUPDATEFLAGS:
11501 {
11502 int32_t indx = ri->d[rINDEX] / 10000;
11503 if (indx < 0 || indx > 2)
11504 {
11505 Z_scripterrlog("Invalid Index passed to Audio->MusicRefreshFlags[]: %d\n", indx);
11506 }
11507 ret = ((FFCore.music_update_flags >> indx) & 1) ? 10000 : 0; break;
11508 }
11509 case DMAPDATAASUBSCRIPT: //word
11510 {
11511 22016 ret = (DMaps[ri->dmapsref].active_sub_script) * 10000; break;
11512 }
11513 case DMAPDATAMAPSCRIPT: //byte
11514 {
11515 ret = (DMaps[ri->dmapsref].onmap_script) * 10000; break;
11516 }
11517 case DMAPDATAPSUBSCRIPT: //word
11518 {
11519 ret = (DMaps[ri->dmapsref].passive_sub_script) * 10000; break;
11520 }
11521 case DMAPDATASUBINITD: //byte[8] --array
11522 {
11523 int32_t indx = ri->d[rINDEX] / 10000;
11524 if ( indx < 0 || indx > 7 )
11525 {
11526 Z_scripterrlog("Invalid index supplied to dmapdata->SubInitD[]: %d\n", indx);
11527 ret = -10000;
11528 break;
11529 }
11530 else
11531 {
11532 ret = DMaps[ri->dmapsref].sub_initD[indx]; break;
11533 }
11534 }
11535
11536 case DMAPDATAMAPINITD: //byte[8] --array
11537 {
11538 int32_t indx = ri->d[rINDEX] / 10000;
11539 if ( indx < 0 || indx > 7 )
11540 {
11541 Z_scripterrlog("Invalid index supplied to dmapdata->MapInitD[]: %d\n", indx);
11542 ret = -10000;
11543 break;
11544 }
11545 else
11546 {
11547 ret = DMaps[ri->dmapsref].onmap_initD[indx]; break;
11548 }
11549 }
11550
11551 case DMAPDATACHARTED:
11552 {
11553 int32_t scr = ri->d[rINDEX] / 10000;
11554 ret = -10000;
11555 if(ri->dmapsref >= MAXDMAPS)
11556 {
11557 Z_scripterrlog("Invalid DMap reference used for dmapdata->Charted[]: %d\n", ri->dmapsref);
11558 }
11559 // else if((DMaps[get_currdmap()].type&dmfTYPE) == dmOVERW)
11560 // {
11561 // Z_scripterrlog("dmapdata->Charted[] cannot presently be used on Overworld-type dmaps\n");
11562 // }
11563 else if(((unsigned)(scr)) > 127)
11564 {
11565 Z_scripterrlog("Invalid index supplied to dmapdata->Charted[]: %d\n", scr);
11566 }
11567 else
11568 {
11569 int32_t col = (scr&15)-(DMaps[ri->dmapsref].type==dmOVERW ? 0 : DMaps[ri->dmapsref].xoff);
11570 if((DMaps[ri->dmapsref].type&dmfTYPE)!=dmOVERW ? (((unsigned)col) > 7) : (((unsigned)col) > 15))
11571 break; //Out-of-bounds; don't attempt read!
11572 int32_t di = (ri->dmapsref << 7) + (scr & 0x7F);
11573 ret = 10000 * game->bmaps[di];
11574 }
11575 break;
11576 }
11577 //case DMAPDATAGRAVITY: //unimplemented
11578 //case DMAPDATAJUMPLAYER: //unimplemented
11579
11580 ///----------------------------------------------------------------------------------------------------//
11581 //messagedata msgd-> variables
11582 case MESSAGEDATANEXT: //W
11583 {
11584 int32_t ID = ri->zmsgref;
11585
11586 if(BC::checkMessage(ID, "messagedata->Next") != SH::_NoError)
11587 {
11588 ret = -10000; break;
11589 }
11590 else
11591 {
11592 ret = ((int32_t)MsgStrings[ID].nextstring) * 10000;
11593 break;
11594 }
11595 }
11596
11597 case MESSAGEDATATILE: //W
11598 {
11599 int32_t ID = ri->zmsgref;
11600
11601 if(BC::checkMessage(ID, "messagedata->Tile") != SH::_NoError)
11602 ret = -10000;
11603 else
11604 ret = ((int32_t)MsgStrings[ID].tile) * 10000;
11605 break;
11606 }
11607
11608 case MESSAGEDATACSET: //b
11609 {
11610 int32_t ID = ri->zmsgref;
11611
11612 if(BC::checkMessage(ID, "messagedata->CSet") != SH::_NoError)
11613 ret = -10000;
11614 else
11615 ret = ((int32_t)MsgStrings[ID].cset) * 10000;
11616 break;
11617 }
11618 case MESSAGEDATATRANS: //BOOL
11619 {
11620 int32_t ID = ri->zmsgref;
11621
11622 if(BC::checkMessage(ID, "messagedata->Transparent") != SH::_NoError)
11623 ret = -10000;
11624 else
11625 ret = ((MsgStrings[ID].trans)?10000:0);
11626 break;
11627 }
11628 case MESSAGEDATAFONT: //B
11629 {
11630 int32_t ID = ri->zmsgref;
11631
11632 if(BC::checkMessage(ID, "messagedata->Font") != SH::_NoError)
11633 ret = -10000;
11634 else
11635 ret = (int32_t)MsgStrings[ID].font * 10000;
11636 break;
11637 }
11638 case MESSAGEDATAX: //SHORT
11639 {
11640 int32_t ID = ri->zmsgref;
11641
11642 if(BC::checkMessage(ID, "messagedata->X") != SH::_NoError)
11643 ret = -10000;
11644 else
11645 ret = ((int32_t)MsgStrings[ID].x) * 10000;
11646 break;
11647 }
11648 case MESSAGEDATAY: //SHORT
11649 {
11650 int32_t ID = ri->zmsgref;
11651
11652 if(BC::checkMessage(ID, "messagedata->Y") != SH::_NoError)
11653 ret = -10000;
11654 else
11655 ret = ((int32_t)MsgStrings[ID].y) * 10000;
11656 break;
11657 }
11658 case MESSAGEDATAW: //UNSIGNED SHORT
11659 {
11660 int32_t ID = ri->zmsgref;
11661
11662 if(BC::checkMessage(ID, "messagedata->Width") != SH::_NoError)
11663 ret = -10000;
11664 else
11665 ret = ((int32_t)MsgStrings[ID].w) * 10000;
11666 break;
11667 }
11668 case MESSAGEDATAH: //UNSIGNED SHORT
11669 {
11670 int32_t ID = ri->zmsgref;
11671
11672 if(BC::checkMessage(ID, "messagedata->Height") != SH::_NoError)
11673 ret = -10000;
11674 else
11675 ret = ((int32_t)MsgStrings[ID].h) * 10000;
11676 break;
11677 }
11678 case MESSAGEDATASFX: //BYTE
11679 {
11680 int32_t ID = ri->zmsgref;
11681
11682 if(BC::checkMessage(ID, "messagedata->Sound") != SH::_NoError)
11683 ret = -10000;
11684 else
11685 ret = ((int32_t)MsgStrings[ID].sfx) * 10000;
11686 break;
11687 }
11688 case MESSAGEDATALISTPOS: //WORD
11689 {
11690 int32_t ID = ri->zmsgref;
11691
11692 if(BC::checkMessage(ID, "messagedata->ListPosition") != SH::_NoError)
11693 ret = -10000;
11694 else
11695 ret = ((int32_t)MsgStrings[ID].listpos) * 10000;
11696 break;
11697 }
11698 case MESSAGEDATAVSPACE: //BYTE
11699 {
11700 int32_t ID = ri->zmsgref;
11701
11702 if(BC::checkMessage(ID, "messagedata->VSpace") != SH::_NoError)
11703 ret = -10000;
11704 else
11705 ret = ((int32_t)MsgStrings[ID].vspace) * 10000;
11706 break;
11707 }
11708 case MESSAGEDATAHSPACE: //BYTE
11709 {
11710 int32_t ID = ri->zmsgref;
11711
11712 if(BC::checkMessage(ID, "messagedata->HSpace") != SH::_NoError)
11713 ret = -10000;
11714 else
11715 ret = ((int32_t)MsgStrings[ID].hspace) * 10000;
11716 break;
11717 }
11718 case MESSAGEDATAFLAGS: //BYTE
11719 {
11720 int32_t ID = ri->zmsgref;
11721
11722 if(BC::checkMessage(ID, "messagedata->Flags") != SH::_NoError)
11723 ret = -10000;
11724 else
11725 ret = ((int32_t)MsgStrings[ID].stringflags) * 10000;
11726 break;
11727 }
11728 case MESSAGEDATAMARGINS: //BYTE, 4
11729 {
11730 int32_t indx = ri->d[rINDEX] / 10000;
11731 if ( indx < 0 || indx > 3 )
11732 {
11733 Z_scripterrlog("Invalid index supplied to messagedata->Margins[]: %d\n", indx);
11734 ret = -10000;
11735 break;
11736 }
11737 int32_t ID = ri->zmsgref;
11738
11739 if(BC::checkMessage(ID, "messagedata->Margins[]") != SH::_NoError)
11740 ret = -10000;
11741 else
11742 ret = ((int32_t)MsgStrings[ID].margins[indx]) * 10000;
11743 break;
11744 }
11745 case MESSAGEDATAPORTTILE: //INT
11746 {
11747 int32_t ID = ri->zmsgref;
11748
11749 if(BC::checkMessage(ID, "messagedata->PortraitTile") != SH::_NoError)
11750 ret = -10000;
11751 else
11752 ret = ((int32_t)MsgStrings[ID].portrait_tile) * 10000;
11753 break;
11754 }
11755 case MESSAGEDATAPORTCSET: //BYTE
11756 {
11757 int32_t ID = ri->zmsgref;
11758
11759 if(BC::checkMessage(ID, "messagedata->PortraitCSet") != SH::_NoError)
11760 ret = -10000;
11761 else
11762 ret = ((int32_t)MsgStrings[ID].portrait_cset) * 10000;
11763 break;
11764 }
11765 case MESSAGEDATAPORTX: //BYTE
11766 {
11767 int32_t ID = ri->zmsgref;
11768
11769 if(BC::checkMessage(ID, "messagedata->PortraitX") != SH::_NoError)
11770 ret = -10000;
11771 else
11772 ret = ((int32_t)MsgStrings[ID].portrait_x) * 10000;
11773 break;
11774 }
11775 case MESSAGEDATAPORTY: //BYTE
11776 {
11777 int32_t ID = ri->zmsgref;
11778
11779 if(BC::checkMessage(ID, "messagedata->PortraitY") != SH::_NoError)
11780 ret = -10000;
11781 else
11782 ret = ((int32_t)MsgStrings[ID].portrait_y) * 10000;
11783 break;
11784 }
11785 case MESSAGEDATAPORTWID: //BYTE
11786 {
11787 int32_t ID = ri->zmsgref;
11788
11789 if(BC::checkMessage(ID, "messagedata->PortraitTileWidth") != SH::_NoError)
11790 ret = -10000;
11791 else
11792 ret = ((int32_t)MsgStrings[ID].portrait_tw) * 10000;
11793 break;
11794 }
11795 case MESSAGEDATAPORTHEI: //BYTE
11796 {
11797 int32_t ID = ri->zmsgref;
11798
11799 if(BC::checkMessage(ID, "messagedata->PortraitTileHeight") != SH::_NoError)
11800 ret = -10000;
11801 else
11802 ret = ((int32_t)MsgStrings[ID].portrait_th) * 10000;
11803 break;
11804 }
11805 case MESSAGEDATATEXTLEN: //BYTE
11806 {
11807 int32_t ID = ri->zmsgref;
11808
11809 if(BC::checkMessage(ID, "messagedata->PortraitTileHeight") != SH::_NoError)
11810 ret = -10000;
11811 else
11812 ret = int32_t(MsgStrings[ID].s.size()) * 10000;
11813 break;
11814 }
11815 case MESSAGEDATATEXTWID:
11816 {
11817 ret = do_msgwidth(ri->zmsgref, "messagedata->TextWidth")*10000;
11818 break;
11819 }
11820 case MESSAGEDATATEXTHEI:
11821 {
11822 ret = do_msgheight(ri->zmsgref, "messagedata->TextHeight")*10000;
11823 break;
11824 }
11825 case MESSAGEDATAFLAGSARR: //BOOL, 7
11826 {
11827 int32_t indx = ri->d[rINDEX] / 10000;
11828 int32_t ID = ri->zmsgref;
11829
11830 if(BC::checkMessage(ID, "messagedata->Flags[]") != SH::_NoError)
11831 ret = -10000;
11832 else
11833 {
11834 switch(indx)
11835 {
11836 case 0:
11837 ret = (MsgStrings[ID].stringflags & STRINGFLAG_WRAP)!=0 ? 10000 : 0;
11838 break;
11839 case 1:
11840 ret = (MsgStrings[ID].stringflags & STRINGFLAG_CONT)!=0 ? 10000 : 0;
11841 break;
11842 case 2: //Not implemented
11843 ret = 0;//ret = (MsgStrings[ID].stringflags & STRINGFLAG_CENTER)!=0 ? 10000 : 0;
11844 break;
11845 case 3: //Not implemented
11846 ret = 0;//ret = (MsgStrings[ID].stringflags & STRINGFLAG_RIGHT)!=0 ? 10000 : 0;
11847 break;
11848 case 4:
11849 ret = (MsgStrings[ID].stringflags & STRINGFLAG_FULLTILE)!=0 ? 10000 : 0;
11850 break;
11851 case 5:
11852 ret = (MsgStrings[ID].stringflags & STRINGFLAG_TRANS_BG)!=0 ? 10000 : 0;
11853 break;
11854 case 6:
11855 ret = (MsgStrings[ID].stringflags & STRINGFLAG_TRANS_FG)!=0 ? 10000 : 0;
11856 break;
11857 default:
11858 Z_scripterrlog("Invalid index supplied to messagedata->Flags[]: %d\n", indx);
11859 ret = -10000;
11860 }
11861 }
11862 break;
11863 }
11864
11865 ///----------------------------------------------------------------------------------------------------//
11866 //combodata cd-> Getter variables
11867 #define GET_COMBO_VAR_INT(member, str) \
11868 { \
11869 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11870 { \
11871 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11872 ret = -10000; \
11873 } \
11874 else \
11875 { \
11876 ret = (combobuf[ri->combosref].member *10000); \
11877 } \
11878 } \
11879
11880 #define GET_COMBO_VAR_BYTE(member, str) \
11881 { \
11882 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11883 { \
11884 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11885 ret = -10000; \
11886 } \
11887 else \
11888 { \
11889 ret = (combobuf[ri->combosref].member *10000); \
11890 } \
11891 } \
11892
11893 #define GET_COMBO_VAR_DWORD(member, str) \
11894 { \
11895 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11896 { \
11897 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11898 ret = -10000; \
11899 } \
11900 else \
11901 { \
11902 ret = (combobuf[ri->combosref].member *10000); \
11903 } \
11904 } \
11905
11906 #define GET_COMBO_VAR_INDEX(member, str, indexbound) \
11907 { \
11908 int32_t indx = ri->d[rINDEX] / 10000; \
11909 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11910 { \
11911 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11912 ret = -10000; \
11913 } \
11914 else if ( indx < 0 || indx >= indexbound ) \
11915 { \
11916 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
11917 ret = -10000; \
11918 } \
11919 else \
11920 { \
11921 ret = (combobuf[ri->combosref].member[indx] * 10000); \
11922 } \
11923 }
11924
11925 #define GET_COMBO_BYTE_INDEX(member, str, indexbound) \
11926 { \
11927 int32_t indx = ri->d[rINDEX] / 10000; \
11928 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11929 { \
11930 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11931 ret = -10000; \
11932 } \
11933 else if ( indx < 0 || indx >= indexbound ) \
11934 { \
11935 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
11936 ret = -10000; \
11937 } \
11938 else \
11939 { \
11940 ret = (combobuf[ri->combosref].member[indx] * 100000); \
11941 } \
11942 }
11943
11944 #define GET_COMBO_FLAG(member, str, indexbound) \
11945 { \
11946 int32_t flag = (value/10000); \
11947 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11948 { \
11949 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11950 } \
11951 else \
11952 { \
11953 ret = (combobuf[ri->combosref].member&flag) ? 10000 : 0); \
11954 } \
11955 } \
11956
11957 //comboclass macros
11958
11959 #define GET_COMBOCLASS_VAR_INT(member, str) \
11960 { \
11961 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11962 { \
11963 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11964 ret = -10000; \
11965 } \
11966 else \
11967 { \
11968 ret = (combo_class_buf[combobuf[ri->combosref].type].member *10000); \
11969 } \
11970 } \
11971
11972 #define GET_COMBOCLASS_VAR_BYTE(member, str) \
11973 { \
11974 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11975 { \
11976 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11977 ret = -10000; \
11978 } \
11979 else \
11980 { \
11981 ret = (combo_class_buf[combobuf[ri->combosref].type].member *10000); \
11982 } \
11983 } \
11984
11985 #define GET_COMBOCLASS_VAR_DWORD(member, str) \
11986 { \
11987 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11988 { \
11989 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11990 ret = -10000; \
11991 } \
11992 else \
11993 { \
11994 ret = (combo_class_buf[combobuf[ri->combosref].type].member *10000); \
11995 } \
11996 } \
11997
11998 #define GET_COMBOCLASS_VAR_INDEX(member, str, indexbound) \
11999 { \
12000 int32_t indx = ri->d[rINDEX] / 10000; \
12001 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
12002 { \
12003 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
12004 ret = -10000; \
12005 } \
12006 else if ( indx < 0 || indx > indexbound ) \
12007 { \
12008 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
12009 ret = -10000; \
12010 } \
12011 else \
12012 { \
12013 ret = (combo_class_buf[combobuf[ri->combosref].type].member[indx] * 10000); \
12014 } \
12015 }
12016
12017 #define GET_COMBOCLASS_BYTE_INDEX(member, str, indexbound) \
12018 { \
12019 int32_t indx = ri->d[rINDEX] / 10000; \
12020 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
12021 { \
12022 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
12023 ret = -10000; \
12024 } \
12025 else if ( indx < 0 || indx > indexbound ) \
12026 { \
12027 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
12028 ret = -10000; \
12029 } \
12030 else \
12031 { \
12032 ret = (combo_class_buf[combobuf[ri->combosref].type].member[indx] * 100000); \
12033 } \
12034 }
12035
12036 #define GET_COMBOCLASS_FLAG(member, str, indexbound) \
12037 { \
12038 int32_t flag = (value/10000); \
12039 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
12040 { \
12041 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
12042 } \
12043 else \
12044 { \
12045 ret = (combo_class_buf[combobuf[ri->combosref].type].member&flag) ? 10000 : 0); \
12046 } \
12047 } \
12048
12049 case COMBOXR:
12050 {
12051 //ri->combosref = id; //'this' pointer
12052 //ri->comboposref = i; //used for X(), Y(), Layer(), and so forth.
12053
1/2
✓ Branch 0 taken 11261 times.
✗ Branch 1 not taken.
11261 if ( curScriptType == ScriptType::Combo )
12054 {
12055 11261 int pos = combopos_ref_to_pos(ri->comboposref);
12056 11261 ret = (( COMBOX(pos) ) * 10000); //comboscriptstack[i]
12057 //this may be wrong...may need a special new var for this, storing the exact combopos
12058 //i is the current script number
12059 11261 }
12060 else
12061 {
12062 Z_scripterrlog("combodata->X() can only be called by combodata scripts, but you tried to use it from script type %s, script token %s\n", ScriptTypeToString(curScriptType), comboscriptmap[ri->combosref].scriptname.c_str() );
12063 ret = -10000;
12064 }
12065 11261 break;
12066 }
12067
12068 case COMBOYR:
12069 {
12070
1/2
✓ Branch 0 taken 11261 times.
✗ Branch 1 not taken.
11261 if ( curScriptType == ScriptType::Combo )
12071 {
12072 11261 int pos = combopos_ref_to_pos(ri->comboposref);
12073 11261 ret = (( COMBOY(pos) ) * 10000); //comboscriptstack[i]
12074 11261 }
12075 else
12076 {
12077 Z_scripterrlog("combodata->Y() can only be called by combodata scripts, but you tried to use it from script type %s, script token %s\n", ScriptTypeToString(curScriptType), comboscriptmap[ri->combosref].scriptname.c_str() );
12078 ret = -10000;
12079 }
12080 11261 break;
12081 }
12082 case COMBOPOSR:
12083 {
12084
1/2
✓ Branch 0 taken 33759 times.
✗ Branch 1 not taken.
33759 if ( curScriptType == ScriptType::Combo )
12085 {
12086 33759 int pos = combopos_ref_to_pos(ri->comboposref);
12087 33759 ret = pos * 10000; //comboscriptstack[i]
12088 33759 }
12089 else
12090 {
12091 Z_scripterrlog("combodata->Pos() can only be called by combodata scripts, but you tried to use it from script type %s, script token %s\n", ScriptTypeToString(curScriptType), comboscriptmap[ri->combosref].scriptname.c_str() );
12092 ret = -10000;
12093 }
12094 33759 break;
12095 }
12096 case COMBOLAYERR:
12097 {
12098
1/2
✓ Branch 0 taken 11044 times.
✗ Branch 1 not taken.
11044 if ( curScriptType == ScriptType::Combo )
12099 {
12100 11044 ret = (( ((ri->comboposref)/176) ) * 10000); //comboscriptstack[i]
12101 11044 }
12102 else
12103 {
12104 Z_scripterrlog("combodata->Pos() can only be called by combodata scripts, but you tried to use it from script type %s, script token %s\n", ScriptTypeToString(curScriptType), comboscriptmap[ri->combosref].scriptname.c_str() );
12105 ret = -10000;
12106 }
12107 11044 break;
12108 }
12109
12110 //NEWCOMBO STRUCT
12111
2/4
✓ Branch 0 taken 4546 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4546 times.
4546 case COMBODTILE: GET_COMBO_VAR_DWORD(tile, "Tile"); break; //word
12112 case COMBODOTILE: GET_COMBO_VAR_DWORD(o_tile, "OriginalTile"); break; //word
12113 case COMBODFRAME: GET_COMBO_VAR_BYTE(cur_frame, "Frame"); break; //char
12114 case COMBODACLK: GET_COMBO_VAR_BYTE(aclk, "AClk"); break; //char
12115 case COMBODASPEED: GET_COMBO_VAR_BYTE(speed, "ASpeed"); break; //char
12116
2/4
✓ Branch 0 taken 4546 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4546 times.
4546 case COMBODFLIP: GET_COMBO_VAR_BYTE(flip, "Flip"); break; //char
12117 case COMBODWALK:
12118 {
12119 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12120 {
12121 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Walk");
12122 ret = -10000;
12123 }
12124 else
12125 {
12126 ret = ((combobuf[ri->combosref].walk&0x0F) *10000);
12127 }
12128 break;
12129 }
12130 case COMBODEFFECT:
12131 {
12132 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12133 {
12134 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Effect");
12135 ret = -10000;
12136 }
12137 else
12138 {
12139 ret = (((combobuf[ri->combosref].walk&0xF0)>>4) *10000);
12140 }
12141 break;
12142 }
12143
2/4
✓ Branch 0 taken 4890 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4890 times.
4890 case COMBODTYPE: GET_COMBO_VAR_BYTE(type, "Type"); break; //char
12144 case COMBODCSET:
12145 {
12146 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12147 {
12148 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "CSet2");
12149 ret = -10000;
12150 }
12151 else
12152 {
12153 bool neg = combobuf[ri->combosref].csets&0x8;
12154 ret = ((combobuf[ri->combosref].csets&0x7) * (neg ? -10000 : 10000));
12155 }
12156 break;
12157 }
12158 case COMBODCSET2FLAGS:
12159 {
12160 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12161 {
12162 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "CSet2Flags");
12163 }
12164 else
12165 {
12166 ret = ((combobuf[ri->combosref].csets & 0xF0) >> 4) * 10000;
12167 }
12168 break;
12169 }
12170 case COMBODFOO: break; //W
12171
2/4
✓ Branch 0 taken 22172 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 22172 times.
22172 case COMBODATASCRIPT: GET_COMBO_VAR_DWORD(script, "Script"); break; //W
12172 case COMBODFRAMES: GET_COMBO_VAR_BYTE(frames, "Frames"); break; //C
12173 case COMBODNEXTD: GET_COMBO_VAR_DWORD(speed, "NextData"); break; //W
12174 case COMBODNEXTC: GET_COMBO_VAR_BYTE(nextcombo, "NextCSet"); break; //C
12175 case COMBODFLAG: GET_COMBO_VAR_BYTE(nextcset, "Flag"); break; //C
12176 case COMBODSKIPANIM: GET_COMBO_VAR_BYTE(skipanim, "SkipAnim"); break; //C
12177 case COMBODNEXTTIMER: GET_COMBO_VAR_DWORD(nexttimer, "NextTimer"); break; //W
12178 case COMBODAKIMANIMY: GET_COMBO_VAR_BYTE(skipanimy, "SkipAnimY"); break; //C
12179 case COMBODANIMFLAGS: GET_COMBO_VAR_BYTE(animflags, "AnimFlags"); break; //C
12180 case COMBODEXPANSION: GET_COMBO_BYTE_INDEX(expansion, "Expansion[]", 6); break; //C , 6 INDICES
12181 case COMBODATTRIBUTES:
12182 {
12183 66 int32_t indx = ri->d[rINDEX] / 10000;
12184
2/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
66 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12185 {
12186 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Attributes[]");
12187 ret = -10000;
12188 }
12189
2/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
66 else if ( indx < 0 || indx > 4 )
12190 {
12191 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "Attributes[]");
12192 ret = -10000;
12193 }
12194 else
12195 {
12196 66 ret = (combobuf[ri->combosref].attributes[indx]);
12197 }
12198 }
12199 66 break;
12200 //case COMBODATAINITD: GET_COMBO_VAR_INDEX(initd, "InitD[]", 2); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
12201 case COMBODATAINITD:
12202 {
12203 1636 int32_t indx = ri->d[rINDEX] / 10000;
12204
2/4
✓ Branch 0 taken 1636 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1636 times.
1636 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12205 {
12206 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "InitD[]");
12207 ret = -10000;
12208 }
12209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1636 times.
1636 else if ( ((unsigned)indx) > 8 )
12210 {
12211 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "InitD[]");
12212 ret = -10000;
12213 }
12214 else
12215 {
12216 1636 ret = (combobuf[ri->combosref].initd[indx] * (get_qr(qr_COMBODATA_INITD_MULT_TENK) ? 10000 : 1));
12217 }
12218 1636 break;
12219 }
12220
4/8
✓ Branch 0 taken 568 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 568 times.
✓ Branch 4 taken 568 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 568 times.
1136 case COMBODATTRIBYTES: GET_COMBO_VAR_INDEX(attribytes, "Attribytes[]", 8); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
12221
4/8
✓ Branch 0 taken 136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
✓ Branch 4 taken 136 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 136 times.
272 case COMBODATTRISHORTS: GET_COMBO_VAR_INDEX(attrishorts, "Attrishorts[]", 8); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
12222 case COMBODUSRFLAGARR:
12223 {
12224 int32_t indx = ri->d[rINDEX] / 10000;
12225 if (ri->combosref < 0 || ri->combosref >(MAXCOMBOS - 1))
12226 {
12227 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", "Flags[]", (ri->combosref * 10000));
12228 ret = 0;
12229 }
12230 else if (((unsigned)indx) > 15)
12231 {
12232 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", "Flags[]", indx);
12233 ret = 0;
12234 }
12235 else
12236 {
12237 ret = (combobuf[ri->combosref].usrflags & 1 << indx) ? 10000L : 0L;
12238 }
12239 break;
12240 }
12241 case COMBODGENFLAGARR:
12242 {
12243 int32_t indx = ri->d[rINDEX] / 10000;
12244 if (ri->combosref < 0 || ri->combosref >(MAXCOMBOS - 1))
12245 {
12246 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", "GenFlags[]", (ri->combosref * 10000));
12247 ret = 0;
12248 }
12249 else if (((unsigned)indx) > 1)
12250 {
12251 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", "GenFlags[]", indx);
12252 ret = 0;
12253 }
12254 else
12255 {
12256 ret = (combobuf[ri->combosref].genflags & (1 << indx)) ? 10000L : 0L;
12257 }
12258 break;
12259 }
12260 case COMBODUSRFLAGS: GET_COMBO_VAR_INT(usrflags, "UserFlags"); break; //LONG
12261 case COMBODTRIGGERFLAGS: GET_COMBO_VAR_INDEX(triggerflags, "TriggerFlags[]", 6); break; //LONG 3 INDICES AS FLAGSETS
12262 case COMBODTRIGGERFLAGS2:
12263 {
12264 int32_t indx = ri->d[rINDEX] / 10000;
12265 ret = -10000;
12266 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12267 {
12268 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TrigFlags[]");
12269 }
12270 else if ( unsigned(indx) >= 32*6 )
12271 {
12272 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "TrigFlags[]");
12273 }
12274 else
12275 {
12276 ret = (combobuf[ri->combosref].triggerflags[indx/32] & (1<<indx%32)) ? 10000L : 0L;
12277 }
12278 break;
12279 }
12280 case COMBODTRIGGERBUTTON:
12281 {
12282 int32_t indx = ri->d[rINDEX] / 10000;
12283 ret = -10000;
12284 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12285 {
12286 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerButton[]");
12287 }
12288 else if ( unsigned(indx) >= 8 )
12289 {
12290 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "TriggerButton[]");
12291 }
12292 else
12293 {
12294 ret = (combobuf[ri->combosref].triggerbtn & (1<<indx)) ? 10000L : 0L;
12295 }
12296 break;
12297 }
12298 case COMBODTRIGGERITEM:
12299 {
12300 ret = -10000;
12301 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12302 {
12303 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerItem");
12304 }
12305 else ret = (combobuf[ri->combosref].triggeritem) * 10000;
12306 break;
12307 }
12308 case COMBODTRIGGERTIMER:
12309 {
12310 ret = -10000;
12311 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12312 {
12313 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerTimer");
12314 }
12315 else ret = (combobuf[ri->combosref].trigtimer) * 10000;
12316 break;
12317 }
12318 case COMBODTRIGGERSFX:
12319 {
12320 ret = -10000;
12321 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12322 {
12323 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerSFX");
12324 }
12325 else ret = (combobuf[ri->combosref].trigsfx) * 10000;
12326 break;
12327 }
12328 case COMBODTRIGGERCHANGECMB:
12329 {
12330 ret = -10000;
12331 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12332 {
12333 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerChange");
12334 }
12335 else ret = (combobuf[ri->combosref].trigchange) * 10000;
12336 break;
12337 }
12338 case COMBODTRIGGERPROX:
12339 {
12340 ret = -10000;
12341 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12342 {
12343 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerProximity");
12344 }
12345 else ret = (combobuf[ri->combosref].trigprox) * 10000;
12346 break;
12347 }
12348 case COMBODTRIGGERLIGHTBEAM:
12349 {
12350 ret = -10000;
12351 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12352 {
12353 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerLightBeam");
12354 }
12355 else ret = (combobuf[ri->combosref].triglbeam) * 10000;
12356 break;
12357 }
12358 case COMBODTRIGGERCTR:
12359 {
12360 ret = -10000;
12361 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12362 {
12363 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerCounter");
12364 }
12365 else ret = (combobuf[ri->combosref].trigctr) * 10000;
12366 break;
12367 }
12368 case COMBODTRIGGERCTRAMNT:
12369 {
12370 ret = -10000;
12371 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12372 {
12373 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerCtrAmount");
12374 }
12375 else ret = (combobuf[ri->combosref].trigctramnt) * 10000;
12376 break;
12377 }
12378 case COMBODTRIGGERCOOLDOWN:
12379 {
12380 ret = -10000;
12381 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12382 {
12383 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerCooldown: %d\n", (ri->combosref*10000));
12384 }
12385 else ret = (combobuf[ri->combosref].trigcooldown) * 10000;
12386 break;
12387 }
12388 case COMBODTRIGGERCOPYCAT:
12389 {
12390 ret = -10000;
12391 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12392 {
12393 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerCopycat: %d\n", (ri->combosref*10000));
12394 }
12395 else ret = (combobuf[ri->combosref].trigcopycat) * 10000;
12396 break;
12397 }
12398 case COMBODTRIGITEMPICKUP:
12399 {
12400 ret = -10000;
12401 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12402 {
12403 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerSpawnItemPickup: %d\n", (ri->combosref*10000));
12404 }
12405 else ret = (combobuf[ri->combosref].spawnip) * 10000;
12406 break;
12407 }
12408 case COMBODTRIGEXSTATE:
12409 {
12410 ret = -10000;
12411 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12412 {
12413 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigExState: %d\n", (ri->combosref*10000));
12414 }
12415 else ret = (combobuf[ri->combosref].exstate) * 10000;
12416 break;
12417 }
12418 case COMBODTRIGSPAWNENEMY:
12419 {
12420 ret = -10000;
12421 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12422 {
12423 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigSpawnEnemy: %d\n", (ri->combosref*10000));
12424 }
12425 else ret = (combobuf[ri->combosref].spawnenemy) * 10000;
12426 break;
12427 }
12428 case COMBODTRIGSPAWNITEM:
12429 {
12430 ret = -10000;
12431 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12432 {
12433 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigSpawnItem: %d\n", (ri->combosref*10000));
12434 }
12435 else ret = (combobuf[ri->combosref].spawnitem) * 10000;
12436 break;
12437 }
12438 case COMBODTRIGCSETCHANGE:
12439 {
12440 ret = -10000;
12441 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12442 {
12443 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigCSetChange: %d\n", (ri->combosref*10000));
12444 }
12445 else ret = (combobuf[ri->combosref].trigcschange) * 10000;
12446 break;
12447 }
12448 case COMBODLIFTGFXCOMBO:
12449 {
12450 ret = -10000;
12451 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12452 {
12453 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXCombo: %d\n", (ri->combosref*10000));
12454 }
12455 else ret = (combobuf[ri->combosref].liftcmb) * 10000;
12456 break;
12457 }
12458 case COMBODLIFTGFXCCSET:
12459 {
12460 ret = -10000;
12461 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12462 {
12463 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXCSet: %d\n", (ri->combosref*10000));
12464 }
12465 else ret = (combobuf[ri->combosref].liftcs) * 10000;
12466 break;
12467 }
12468 case COMBODLIFTUNDERCMB:
12469 {
12470 ret = -10000;
12471 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12472 {
12473 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftUnderCombo: %d\n", (ri->combosref*10000));
12474 }
12475 else ret = (combobuf[ri->combosref].liftundercmb) * 10000;
12476 break;
12477 }
12478 case COMBODLIFTUNDERCS:
12479 {
12480 ret = -10000;
12481 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12482 {
12483 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftUnderCSet: %d\n", (ri->combosref*10000));
12484 }
12485 else ret = (combobuf[ri->combosref].liftundercs) * 10000;
12486 break;
12487 }
12488 case COMBODLIFTDAMAGE:
12489 {
12490 ret = -10000;
12491 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12492 {
12493 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftDamage: %d\n", (ri->combosref*10000));
12494 }
12495 else ret = (combobuf[ri->combosref].liftdmg) * 10000;
12496 break;
12497 }
12498 case COMBODLIFTLEVEL:
12499 {
12500 ret = -10000;
12501 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12502 {
12503 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftLevel: %d\n", (ri->combosref*10000));
12504 }
12505 else ret = (combobuf[ri->combosref].liftlvl) * 10000;
12506 break;
12507 }
12508 case COMBODLIFTITEM:
12509 {
12510 ret = -10000;
12511 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12512 {
12513 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftItem: %d\n", (ri->combosref*10000));
12514 }
12515 else ret = (combobuf[ri->combosref].liftitm) * 10000;
12516 break;
12517 }
12518 case COMBODLIFTFLAGS:
12519 {
12520 ret = -10000;
12521 int32_t indx = ri->d[rINDEX] / 10000;
12522 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12523 {
12524 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftFlags[]: %d\n", (ri->combosref*10000));
12525 break;
12526 }
12527 if ( unsigned(indx) > 7 )
12528 {
12529 Z_scripterrlog("Invalid index supplied to combodata->LiftFlags[]: %d\n", indx);
12530 break;
12531 }
12532 ret = (combobuf[ri->combosref].liftflags & (1<<indx)) ? 10000 : 0;
12533 break;
12534 }
12535 case COMBODLIFTGFXTYPE:
12536 {
12537 ret = -10000;
12538 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12539 {
12540 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXType: %d\n", (ri->combosref*10000));
12541 }
12542 else ret = (combobuf[ri->combosref].liftgfx) * 10000;
12543 break;
12544 }
12545 case COMBODLIFTGFXSPRITE:
12546 {
12547 ret = -10000;
12548 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12549 {
12550 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXSprite: %d\n", (ri->combosref*10000));
12551 }
12552 else ret = (combobuf[ri->combosref].liftsprite) * 10000;
12553 break;
12554 }
12555 case COMBODLIFTSFX:
12556 {
12557 ret = -10000;
12558 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12559 {
12560 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftSFX: %d\n", (ri->combosref*10000));
12561 }
12562 else ret = (combobuf[ri->combosref].liftsfx) * 10000;
12563 break;
12564 }
12565 case COMBODLIFTBREAKSPRITE:
12566 {
12567 ret = -10000;
12568 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12569 {
12570 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftBreakSprite: %d\n", (ri->combosref*10000));
12571 }
12572 else ret = (combobuf[ri->combosref].liftbreaksprite) * 10000;
12573 break;
12574 }
12575 case COMBODLIFTBREAKSFX:
12576 {
12577 ret = -10000;
12578 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12579 {
12580 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftBreakSFX: %d\n", (ri->combosref*10000));
12581 }
12582 else ret = (combobuf[ri->combosref].liftbreaksfx) * 10000;
12583 break;
12584 }
12585 case COMBODLIFTHEIGHT:
12586 {
12587 ret = -10000;
12588 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12589 {
12590 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftHeight: %d\n", (ri->combosref*10000));
12591 }
12592 else ret = (combobuf[ri->combosref].lifthei) * 10000;
12593 break;
12594 }
12595 case COMBODLIFTTIME:
12596 {
12597 ret = -10000;
12598 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12599 {
12600 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftTime: %d\n", (ri->combosref*10000));
12601 }
12602 else ret = (combobuf[ri->combosref].lifttime) * 10000;
12603 break;
12604 }
12605 case COMBODLIFTWEAPONITEM:
12606 {
12607 ret = -10000;
12608 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12609 {
12610 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftWeaponItem: %d\n", (ri->combosref*10000));
12611 }
12612 else ret = (combobuf[ri->combosref].lift_parent_item) * 10000;
12613 break;
12614 }
12615 case COMBODTRIGGERLSTATE:
12616 {
12617 ret = -10000;
12618 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12619 {
12620 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigLevelState: %d\n", (ri->combosref*10000));
12621 }
12622 else ret = (combobuf[ri->combosref].trig_lstate) * 10000;
12623 break;
12624 }
12625 case COMBODTRIGGERGSTATE:
12626 {
12627 ret = -10000;
12628 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12629 {
12630 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGlobalState: %d\n", (ri->combosref*10000));
12631 }
12632 else ret = (combobuf[ri->combosref].trig_gstate) * 10000;
12633 break;
12634 }
12635 case COMBODTRIGGERGROUP:
12636 {
12637 ret = -10000;
12638 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12639 {
12640 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGroup: %d\n", (ri->combosref*10000));
12641 }
12642 else ret = (combobuf[ri->combosref].trig_group) * 10000;
12643 break;
12644 }
12645 case COMBODTRIGGERGROUPVAL:
12646 {
12647 ret = -10000;
12648 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12649 {
12650 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGroupVal: %d\n", (ri->combosref*10000));
12651 }
12652 else ret = (combobuf[ri->combosref].trig_group_val) * 10000;
12653 break;
12654 }
12655 case COMBODTRIGGERGTIMER:
12656 {
12657 ret = -10000;
12658 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12659 {
12660 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGStateTimer: %d\n", (ri->combosref*10000));
12661 }
12662 else ret = (combobuf[ri->combosref].trig_statetime) * 10000;
12663 break;
12664 }
12665 case COMBODTRIGGERGENSCRIPT:
12666 {
12667 ret = -10000;
12668 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12669 {
12670 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGenScript: %d\n", (ri->combosref*10000));
12671 }
12672 else ret = (combobuf[ri->combosref].trig_genscr) * 10000;
12673 break;
12674 }
12675
12676 case COMBODTRIGGERLEVEL: GET_COMBO_VAR_INT(triggerlevel, "TriggerLevel"); break; //LONG
12677 10673 case COMBODATAID: ret = (ri->combosref*10000); break;
12678 //COMBOCLASS STRUCT
12679 //case COMBODNAME: //CHAR[64], STRING
12680 case COMBODBLOCKNPC: GET_COMBOCLASS_VAR_BYTE(block_enemies, "BlockNPC"); break; //C
12681 case COMBODBLOCKHOLE: GET_COMBOCLASS_VAR_BYTE(block_hole, "BlockHole"); break; //C
12682 case COMBODBLOCKTRIG: GET_COMBOCLASS_VAR_BYTE(block_trigger, "BlockTrigger"); break; //C
12683 case COMBODBLOCKWEAPON: GET_COMBOCLASS_BYTE_INDEX(block_weapon, "BlockWeapon[]", 32); break; //C, 32 INDICES
12684 case COMBODCONVXSPEED: GET_COMBOCLASS_VAR_DWORD(conveyor_x_speed, "ConveyorSpeedX"); break; //SHORT
12685 case COMBODCONVYSPEED: GET_COMBOCLASS_VAR_DWORD(conveyor_y_speed, "ConveyorSpeedY"); break; //SHORT
12686 case COMBODSPAWNNPC: GET_COMBOCLASS_VAR_DWORD(create_enemy, "SpawnNPC"); break; //W
12687 case COMBODSPAWNNPCWHEN: GET_COMBOCLASS_VAR_BYTE(create_enemy_when, "SpawnNPCWhen"); break; //C
12688 case COMBODSPAWNNPCCHANGE: GET_COMBOCLASS_VAR_INT(create_enemy_change, "SpawnNPCChange"); break; //LONG
12689 case COMBODDIRCHANGETYPE: GET_COMBOCLASS_VAR_BYTE(directional_change_type, "DirChange"); break; //C
12690 case COMBODDISTANCECHANGETILES: GET_COMBOCLASS_VAR_INT(distance_change_tiles, "DistanceChangeTiles"); break; //LONG
12691 case COMBODDIVEITEM: GET_COMBOCLASS_VAR_DWORD(dive_item, "DiveItem"); break; //SHORT
12692 case COMBODDOCK: GET_COMBOCLASS_VAR_BYTE(dock, "Dock"); break; //C
12693 case COMBODFAIRY: GET_COMBOCLASS_VAR_BYTE(fairy, "Fairy"); break; //C
12694 case COMBODFFATTRCHANGE: GET_COMBOCLASS_VAR_BYTE(ff_combo_attr_change, "FFCAttributeChange"); break; //C
12695 case COMBODFOORDECOTILE: GET_COMBOCLASS_VAR_INT(foot_decorations_tile, "DecorationTile"); break; //LONG
12696 case COMBODFOORDECOTYPE: GET_COMBOCLASS_VAR_BYTE(foot_decorations_type, "DecorationType"); break; //C
12697 case COMBODHOOKSHOTPOINT: GET_COMBOCLASS_VAR_BYTE(hookshot_grab_point, "Hookshot"); break; //C
12698 case COMBODLADDERPASS: GET_COMBOCLASS_VAR_BYTE(ladder_pass, "Ladder"); break; //C
12699 case COMBODLOCKBLOCK: GET_COMBOCLASS_VAR_BYTE(lock_block_type, "LockBlock"); break; //C
12700 case COMBODLOCKBLOCKCHANGE: GET_COMBOCLASS_VAR_INT(lock_block_change, "LockBlockChange"); break; //LONG
12701 case COMBODMAGICMIRROR: GET_COMBOCLASS_VAR_BYTE(magic_mirror_type, "Mirror"); break; //C
12702 case COMBODMODHPAMOUNT: GET_COMBOCLASS_VAR_DWORD(modify_hp_amount, "DamageAmount"); break; //SHORT
12703 case COMBODMODHPDELAY: GET_COMBOCLASS_VAR_BYTE(modify_hp_delay, "DamageDelay"); break; //C
12704 case COMBODMODHPTYPE: GET_COMBOCLASS_VAR_BYTE(modify_hp_type, "DamageType"); break; //C
12705 case COMBODNMODMPAMOUNT: GET_COMBOCLASS_VAR_DWORD(modify_mp_amount, "MagicAmount"); break; //SHORT
12706 case COMBODMODMPDELAY: GET_COMBOCLASS_VAR_BYTE(modify_mp_delay, "MagicDelay"); break; //C
12707 case COMBODMODMPTYPE: GET_COMBOCLASS_VAR_BYTE(modify_mp_type, "MagicType"); break; //C
12708 case COMBODNOPUSHBLOCK: GET_COMBOCLASS_VAR_BYTE(no_push_blocks, "NoPushBlocks"); break; //C
12709 case COMBODOVERHEAD: GET_COMBOCLASS_VAR_BYTE(overhead, "Overhead"); break; //C
12710 case COMBODPLACENPC: GET_COMBOCLASS_VAR_BYTE(place_enemy, "PlaceNPC"); break; //C
12711 case COMBODPUSHDIR: GET_COMBOCLASS_VAR_BYTE(push_direction, "PushDir"); break; //C
12712 case COMBODPUSHWAIT: GET_COMBOCLASS_VAR_BYTE(push_wait, "PushDelay"); break; //C
12713 case COMBODPUSHHEAVY: GET_COMBOCLASS_VAR_BYTE(push_weight, "PushHeavy"); break; //C
12714 case COMBODPUSHED: GET_COMBOCLASS_VAR_BYTE(pushed, "Pushed"); break; //C
12715 case COMBODRAFT: GET_COMBOCLASS_VAR_BYTE(raft, "Raft"); break; //C
12716 case COMBODRESETROOM: GET_COMBOCLASS_VAR_BYTE(reset_room, "ResetRoom"); break; //C
12717 case COMBODSAVEPOINTTYPE: GET_COMBOCLASS_VAR_BYTE(save_point_type, "SavePoint"); break; //C
12718 case COMBODSCREENFREEZETYPE: GET_COMBOCLASS_VAR_BYTE(screen_freeze_type, "FreezeScreen"); break; //C
12719 case COMBODSECRETCOMBO: GET_COMBOCLASS_VAR_BYTE(secret_combo, "SecretCombo"); break; //C
12720 case COMBODSINGULAR: GET_COMBOCLASS_VAR_BYTE(singular, "Singular"); break; //C
12721 case COMBODSLOWWALK: GET_COMBOCLASS_VAR_BYTE(slow_movement, "SlowWalk"); break; //C
12722 case COMBODSTATUETYPE: GET_COMBOCLASS_VAR_BYTE(statue_type, "Statue"); break; //C
12723 case COMBODSTEPTYPE: GET_COMBOCLASS_VAR_BYTE(step_type, "Step"); break; //C
12724 case COMBODSTEPCHANGEINTO: GET_COMBOCLASS_VAR_INT(step_change_to, "StepChange"); break; //LONG
12725 case COMBODSTRIKEWEAPONS: GET_COMBOCLASS_BYTE_INDEX(strike_weapons, "Strike[]", 32); break; //BYTE, 32 INDICES.
12726 case COMBODSTRIKEREMNANTS: GET_COMBOCLASS_VAR_INT(strike_remnants, "StrikeRemnants"); break; //LONG
12727 case COMBODSTRIKEREMNANTSTYPE: GET_COMBOCLASS_VAR_BYTE(strike_remnants_type, "StrikeRemnantsType"); break; //C
12728 case COMBODSTRIKECHANGE: GET_COMBOCLASS_VAR_INT(strike_change, "StrikeChange"); break; //LONG
12729 case COMBODSTRIKEITEM: GET_COMBOCLASS_VAR_DWORD(strike_item, "StrikeItem"); break; //SHORT
12730 case COMBODTOUCHITEM: GET_COMBOCLASS_VAR_DWORD(touch_item, "TouchItem"); break; //SHORT
12731 case COMBODTOUCHSTAIRS: GET_COMBOCLASS_VAR_BYTE(touch_stairs, "TouchStairs"); break; //C
12732 case COMBODTRIGGERTYPE: GET_COMBOCLASS_VAR_BYTE(trigger_type, "TriggerType"); break; //C
12733 case COMBODTRIGGERSENS: GET_COMBOCLASS_VAR_BYTE(trigger_sensitive, "TriggerSensitivity"); break; //C
12734 case COMBODWARPTYPE: GET_COMBOCLASS_VAR_BYTE(warp_type, "Warp"); break; //C
12735 case COMBODWARPSENS: GET_COMBOCLASS_VAR_BYTE(warp_sensitive, "WarpSensitivity"); break; //C
12736 case COMBODWARPDIRECT: GET_COMBOCLASS_VAR_BYTE(warp_direct, "WarpDirect"); break; //C
12737 case COMBODWARPLOCATION: GET_COMBOCLASS_VAR_BYTE(warp_location, "WarpLocation"); break; //C
12738 case COMBODWATER: GET_COMBOCLASS_VAR_BYTE(water, "Liquid"); break; //C
12739 case COMBODWHISTLE: GET_COMBOCLASS_VAR_BYTE(whistle, "Whistle"); break; //C
12740 case COMBODWINGAME: GET_COMBOCLASS_VAR_BYTE(win_game, "WinGame"); break; //C
12741 case COMBODBLOCKWPNLEVEL: GET_COMBOCLASS_VAR_BYTE(block_weapon_lvl, "BlockWeaponLevel"); break; //C
12742
12743
12744
12745 ///----------------------------------------------------------------------------------------------------//
12746 //npcdata nd-> variables
12747
12748 //npcdata nd->member variable
12749 #define GET_NPCDATA_VAR_INT32(member, str) \
12750 { \
12751 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12752 { \
12753 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12754 ret = -10000; \
12755 } \
12756 else \
12757 { \
12758 ret = (guysbuf[ri->npcdataref].member *10000); \
12759 } \
12760 } \
12761
12762 #define GET_NPCDATA_VAR_BYTE(member, str) \
12763 { \
12764 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12765 { \
12766 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12767 ret = -10000; \
12768 } \
12769 else \
12770 { \
12771 ret = (guysbuf[ri->npcdataref].member *10000); \
12772 } \
12773 } \
12774
12775 #define GET_NPCDATA_VAR_INT16(member, str) \
12776 { \
12777 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12778 { \
12779 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12780 ret = -10000; \
12781 } \
12782 else \
12783 { \
12784 ret = (guysbuf[ri->npcdataref].member *10000); \
12785 } \
12786 } \
12787
12788 #define GET_NPCDATA_VAR_INDEX(member, str, indexbound) \
12789 { \
12790 int32_t indx = ri->d[rINDEX] / 10000; \
12791 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12792 { \
12793 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12794 ret = -10000; \
12795 } \
12796 else if ( (unsigned)indx > indexbound ) \
12797 { \
12798 Z_scripterrlog("Invalid Array Index passed to npcdata->%s: %d\n", str, indx); \
12799 ret = -10000; \
12800 } \
12801 else \
12802 { \
12803 ret = (guysbuf[ri->npcdataref].member[indx] * 10000); \
12804 } \
12805 }
12806
12807 #define GET_NPCDATA_BYTE_INDEX(member, str, indexbound) \
12808 { \
12809 int32_t indx = ri->d[rINDEX] / 10000; \
12810 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12811 { \
12812 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12813 ret = -10000; \
12814 } \
12815 else if ( (unsigned)indx > indexbound ) \
12816 { \
12817 Z_scripterrlog("Invalid Array Index passed to npcdata->%s: %d\n", str, indx); \
12818 ret = -10000; \
12819 } \
12820 else \
12821 { \
12822 ret = (guysbuf[ri->npcdataref].member[indx] * 100000); \
12823 } \
12824 }
12825
12826 #define GET_NPCDATA_FLAG(member, str, indexbound) \
12827 { \
12828 int32_t flag = (value/10000); \
12829 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12830 { \
12831 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12832 } \
12833 else \
12834 { \
12835 ret = (guysbuf[ID].member&flag) ? 10000 : 0); \
12836 } \
12837 } \
12838
12839 case NPCDATATILE: GET_NPCDATA_VAR_BYTE(tile, "Tile"); break;
12840 case NPCDATAWIDTH: GET_NPCDATA_VAR_BYTE(width, "Width"); break;
12841 case NPCDATAHEIGHT: GET_NPCDATA_VAR_BYTE(height, "Height"); break;
12842 case NPCDATAFLAGS: GET_NPCDATA_VAR_INT16(flags, "Flags"); break; //16 b its
12843 case NPCDATAFLAGS2: GET_NPCDATA_VAR_INT16(flags2, "Flags2"); break; //16 bits
12844 case NPCDATASTILE: GET_NPCDATA_VAR_BYTE(s_tile, "STile"); break;
12845 case NPCDATASWIDTH: GET_NPCDATA_VAR_BYTE(s_width, "SWidth"); break;
12846 case NPCDATASHEIGHT: GET_NPCDATA_VAR_BYTE(s_height, "SHeight"); break;
12847 case NPCDATAETILE: GET_NPCDATA_VAR_INT32(e_tile, "ExTile"); break;
12848 case NPCDATAEWIDTH: GET_NPCDATA_VAR_BYTE(e_width, "ExWidth"); break;
12849 case NPCDATAEHEIGHT: GET_NPCDATA_VAR_BYTE(e_height, "ExHeight"); break;
12850 case NPCDATAHP: GET_NPCDATA_VAR_INT16(hp, "HP"); break;
12851 case NPCDATAFAMILY: GET_NPCDATA_VAR_INT16(family, "Family"); break;
12852 case NPCDATACSET: GET_NPCDATA_VAR_INT16(cset, "CSet"); break;
12853 case NPCDATAANIM: GET_NPCDATA_VAR_INT16(anim, "Anim"); break;
12854 case NPCDATAEANIM: GET_NPCDATA_VAR_INT16(e_anim, "ExAnim"); break;
12855 case NPCDATAFRAMERATE: GET_NPCDATA_VAR_INT16(frate, "Framerate"); break;
12856 case NPCDATAEFRAMERATE: GET_NPCDATA_VAR_INT16(e_frate, "ExFramerate"); break;
12857 case NPCDATATOUCHDAMAGE: GET_NPCDATA_VAR_INT16(dp, "TouchDamage"); break;
12858 case NPCDATAWEAPONDAMAGE: GET_NPCDATA_VAR_INT16(wdp, "WeaponDamage"); break;
12859 case NPCDATAWEAPON: GET_NPCDATA_VAR_INT16(weapon, "Weapon"); break;
12860 case NPCDATARANDOM: GET_NPCDATA_VAR_INT16(rate, "Random"); break;
12861 case NPCDATAHALT: GET_NPCDATA_VAR_INT16(hrate, "Haltrate"); break;
12862 case NPCDATASTEP: GET_NPCDATA_VAR_INT16(step, "Step"); break;
12863 case NPCDATAHOMING: GET_NPCDATA_VAR_INT16(homing, "Homing"); break;
12864 case NPCDATAHUNGER: GET_NPCDATA_VAR_INT16(grumble, "Hunger"); break;
12865 case NPCDATADROPSET: GET_NPCDATA_VAR_INT16(item_set, "Dropset"); break;
12866 case NPCDATABGSFX: GET_NPCDATA_VAR_INT16(bgsfx, "BGSFX"); break;
12867 case NPCDATADEATHSFX: GET_NPCDATA_VAR_BYTE(deadsfx, "DeathSFX"); break;
12868 case NPCDATAHITSFX: GET_NPCDATA_VAR_BYTE(hitsfx, "HitSFX"); break;
12869 case NPCDATAXOFS: GET_NPCDATA_VAR_INT32(xofs, "DrawXOffset"); break;
12870 case NPCDATAYOFS: GET_NPCDATA_VAR_INT32(yofs, "DrawYOffset"); break;
12871 case NPCDATAZOFS: GET_NPCDATA_VAR_INT32(zofs, "DrawZOffset"); break;
12872 case NPCDATAHXOFS: GET_NPCDATA_VAR_INT32(hxofs, "HitXOffset"); break;
12873 case NPCDATAHYOFS: GET_NPCDATA_VAR_INT32(hyofs, "HitYOffset"); break;
12874 case NPCDATAHITWIDTH: GET_NPCDATA_VAR_INT32(hxsz, "HitWidth"); break;
12875 case NPCDATAHITHEIGHT: GET_NPCDATA_VAR_INT32(hysz, "HitHeight"); break;
12876 case NPCDATAHITZ: GET_NPCDATA_VAR_INT32(hzsz, "HitZHeight"); break;
12877 case NPCDATASCRIPT: GET_NPCDATA_VAR_INT32(script, "Script"); break;
12878 case NPCDATATILEWIDTH: GET_NPCDATA_VAR_INT32(txsz, "TileWidth"); break;
12879 case NPCDATATILEHEIGHT: GET_NPCDATA_VAR_INT32(tysz, "TileHeight"); break;
12880 case NPCDATAWPNSPRITE: GET_NPCDATA_VAR_INT32(wpnsprite, "WeaponSprite"); break;
12881 case NPCDATAWEAPONSCRIPT: GET_NPCDATA_VAR_INT32(weaponscript, "WeaponScript"); break;
12882 case NPCDATADEFENSE: GET_NPCDATA_VAR_INDEX(defense, "Defense", 42); break;
12883 case NPCDATAINITD: GET_NPCDATA_VAR_INDEX(initD, "InitD", 8); break;
12884 case NPCDATAWEAPONINITD: GET_NPCDATA_VAR_INDEX(weap_initiald, "WeaponInitD", 8); break;
12885 case NPCDATASIZEFLAG: GET_NPCDATA_VAR_INT32(SIZEflags, "SizeFlags"); break;
12886
12887 case NPCDATAFROZENTILE: GET_NPCDATA_VAR_INT32(frozentile, "FrozenTile"); break;
12888 case NPCDATAFROZENCSET: GET_NPCDATA_VAR_INT32(frozencset, "FrozenCSet"); break;
12889
12890
12891 case NPCDATAATTRIBUTE:
12892 {
12893 int32_t indx = ri->d[rINDEX] / 10000;
12894 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
12895 {
12896 Z_scripterrlog("Invalid Sprite ID passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
12897 ret = -10000;
12898 }
12899 else if ( indx < 0 || indx > MAX_NPC_ATRIBUTES )
12900 {
12901 Z_scripterrlog("Invalid Array Index passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
12902 ret = -10000;
12903 }
12904 else
12905 {
12906 switch(indx)
12907 {
12908 case 0: ret = (guysbuf[ri->npcdataref].misc1 * 10000); break;
12909 case 1: ret = (guysbuf[ri->npcdataref].misc2 * 10000); break;
12910 case 2: ret = (guysbuf[ri->npcdataref].misc3 * 10000); break;
12911 case 3: ret = (guysbuf[ri->npcdataref].misc4 * 10000); break;
12912 case 4: ret = (guysbuf[ri->npcdataref].misc5 * 10000); break;
12913 case 5: ret = (guysbuf[ri->npcdataref].misc6 * 10000); break;
12914 case 6: ret = (guysbuf[ri->npcdataref].misc7 * 10000); break;
12915 case 7: ret = (guysbuf[ri->npcdataref].misc8 * 10000); break;
12916 case 8: ret = (guysbuf[ri->npcdataref].misc9 * 10000); break;
12917 case 9: ret = (guysbuf[ri->npcdataref].misc10 * 10000); break;
12918 case 10: ret = (guysbuf[ri->npcdataref].misc11 * 10000); break;
12919 case 11: ret = (guysbuf[ri->npcdataref].misc12 * 10000); break;
12920 case 12: ret = (guysbuf[ri->npcdataref].misc13 * 10000); break;
12921 case 13: ret = (guysbuf[ri->npcdataref].misc14 * 10000); break;
12922 case 14: ret = (guysbuf[ri->npcdataref].misc15 * 10000); break;
12923 case 15: ret = (guysbuf[ri->npcdataref].misc16 * 10000); break;
12924 case 16: ret = (guysbuf[ri->npcdataref].misc17 * 10000); break;
12925 case 17: ret = (guysbuf[ri->npcdataref].misc18* 10000); break;
12926 case 18: ret = (guysbuf[ri->npcdataref].misc19 * 10000); break;
12927 case 19: ret = (guysbuf[ri->npcdataref].misc20 * 10000); break;
12928 case 20: ret = (guysbuf[ri->npcdataref].misc21 * 10000); break;
12929 case 21: ret = (guysbuf[ri->npcdataref].misc22 * 10000); break;
12930 case 22: ret = (guysbuf[ri->npcdataref].misc23 * 10000); break;
12931 case 23: ret = (guysbuf[ri->npcdataref].misc24 * 10000); break;
12932 case 24: ret = (guysbuf[ri->npcdataref].misc25 * 10000); break;
12933 case 25: ret = (guysbuf[ri->npcdataref].misc26 * 10000); break;
12934 case 26: ret = (guysbuf[ri->npcdataref].misc27 * 10000); break;
12935 case 27: ret = (guysbuf[ri->npcdataref].misc28 * 10000); break;
12936 case 28: ret = (guysbuf[ri->npcdataref].misc29 * 10000); break;
12937 case 29: ret = (guysbuf[ri->npcdataref].misc30 * 10000); break;
12938 case 30: ret = (guysbuf[ri->npcdataref].misc31 * 10000); break;
12939 case 31: ret = (guysbuf[ri->npcdataref].misc32 * 10000); break;
12940
12941
12942
12943 default:
12944 {
12945 Z_scripterrlog("Invalid Array Index passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
12946 ret = -10000;
12947 break;
12948 }
12949 }
12950
12951 }
12952 break;
12953 }
12954
12955 case NPCDATABEHAVIOUR:
12956 {
12957 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
12958 {
12959 ret = -10000;
12960 break;
12961 }
12962 int32_t index = vbound(ri->d[rINDEX]/10000,0,4);
12963 switch(index)
12964 {
12965 case 0:
12966 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG1)?10000:0; break;
12967 case 1:
12968 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG2)?10000:0; break;
12969 case 2:
12970 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG3)?10000:0; break;
12971 case 3:
12972 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG4)?10000:0; break;
12973 case 4:
12974 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG5)?10000:0; break;
12975 case 5:
12976 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG6)?10000:0; break;
12977 case 6:
12978 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG7)?10000:0; break;
12979 case 7:
12980 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG8)?10000:0; break;
12981 case 8:
12982 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG9)?10000:0; break;
12983 case 9:
12984 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG10)?10000:0; break;
12985 case 10:
12986 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG11)?10000:0; break;
12987 case 11:
12988 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG12)?10000:0; break;
12989 case 12:
12990 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG13)?10000:0; break;
12991 case 13:
12992 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG14)?10000:0; break;
12993 case 14:
12994 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG15)?10000:0; break;
12995 case 15:
12996 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG16)?10000:0; break;
12997
12998
12999 default:
13000 ret = 0; break;
13001 }
13002
13003 break;
13004 }
13005
13006 case NPCDATASHIELD:
13007 {
13008 int32_t indx = ri->d[rINDEX] / 10000;
13009 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
13010 {
13011 Z_scripterrlog("Invalid NPC ID passed to npcdata->Shield[]: %d\n", (ri->npcdataref*10000));
13012 ret = -10000;
13013 break;
13014 }
13015 else
13016 {
13017 switch(indx)
13018 {
13019 case 0:
13020 {
13021 ret = ((guysbuf[ri->npcdataref].flags&inv_front) ? 10000 : 0);
13022 break;
13023 }
13024 case 1:
13025 {
13026 ret = ((guysbuf[ri->npcdataref].flags&inv_left) ? 10000 : 0);
13027 break;
13028 }
13029 case 2:
13030 {
13031 ret = ((guysbuf[ri->npcdataref].flags&inv_right) ? 10000 : 0);
13032 break;
13033 }
13034 case 3:
13035 {
13036 ret = ((guysbuf[ri->npcdataref].flags&inv_back) ? 10000 : 0);
13037 break;
13038 }
13039 case 4:
13040 {
13041 ret = ((guysbuf[ri->npcdataref].flags&guy_bkshield) ? 10000 : 0);
13042 break;
13043 }
13044 default:
13045 {
13046 Z_scripterrlog("Invalid Array Index passed to npcdata->Shield[]: %d\n", indx);
13047 ret = -10000;
13048 break;
13049 }
13050 }
13051 }
13052 }
13053 break;
13054
13055 case NPCDSHADOWSPR:
13056 {
13057 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
13058 {
13059 Z_scripterrlog("Invalid NPC ID passed to npcdata->ShadowSprite: %d\n", (ri->npcdataref*10000));
13060 ret = -10000;
13061 }
13062 else
13063 {
13064 ret = guysbuf[ri->npcdataref].spr_shadow * 10000;
13065 }
13066 break;
13067 }
13068 case NPCDSPAWNSPR:
13069 {
13070 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
13071 {
13072 Z_scripterrlog("Invalid NPC ID passed to npcdata->SpawnSprite: %d\n", (ri->npcdataref*10000));
13073 ret = -10000;
13074 }
13075 else
13076 {
13077 ret = guysbuf[ri->npcdataref].spr_spawn * 10000;
13078 }
13079 break;
13080 }
13081 case NPCDDEATHSPR:
13082 {
13083 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
13084 {
13085 Z_scripterrlog("Invalid NPC ID passed to npcdata->DeathSprite: %d\n", (ri->npcdataref*10000));
13086 ret = -10000;
13087 }
13088 else
13089 {
13090 ret = guysbuf[ri->npcdataref].spr_death * 10000;
13091 }
13092 break;
13093 }
13094
13095 case NPCMATCHINITDLABEL: //Same form as SetScreenD()
13096 //bool npcdata->MatchInitDLabel("label", d)
13097 {
13098
13099 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
13100 {
13101 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), "MatchInitDLabel()");
13102 ret = 0;
13103 break;
13104 }
13105
13106 int32_t arrayptr = get_register(sarg1) / 10000;
13107 int32_t init_d_index = get_register(sarg2) / 10000;
13108
13109 string name;
13110 ArrayH::getString(arrayptr, name, 256); // What's the limit on name length?
13111
13112 bool match = (!( strcmp(name.c_str(), guysbuf[ri->npcdataref].initD_label[init_d_index] )));
13113
13114 ret = ( match ? 10000 : 0 );
13115 break;
13116 }
13117
13118 ///----------------------------------------------------------------------------------------------------//
13119 //Dropset Variables
13120
13121 case DROPSETITEMS:
13122 {
13123 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
13124 {
13125 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
13126 ret = -10000;
13127 break;
13128 }
13129 int32_t indx = ri->d[rINDEX]/10000;
13130 if(indx < 0 || indx > 9)
13131 {
13132 Z_scripterrlog("Invalid index passed to dropdata->Items[]: %d\n", indx);
13133 ret = -10000;
13134 }
13135 else
13136 {
13137 ret = item_drop_sets[ri->dropsetref].item[indx] * 10000;
13138 }
13139 break;
13140 }
13141 case DROPSETCHANCES:
13142 {
13143 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
13144 {
13145 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
13146 ret = -10000;
13147 break;
13148 }
13149 int32_t indx = ri->d[rINDEX]/10000;
13150 if(indx < 0 || indx > 9)
13151 {
13152 Z_scripterrlog("Invalid index passed to dropdata->Chances[]: %d\n", indx);
13153 ret = -10000;
13154 }
13155 else
13156 {
13157 ret = item_drop_sets[ri->dropsetref].chance[indx+1] * 10000; //+1 is because '0' is 'nothing''s chance
13158 }
13159 break;
13160 }
13161 case DROPSETNULLCHANCE:
13162 {
13163 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
13164 {
13165 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
13166 ret = -10000;
13167 break;
13168 }
13169 ret = item_drop_sets[ri->dropsetref].chance[0] * 10000;
13170 break;
13171 }
13172 case DROPSETCHOOSE:
13173 {
13174 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
13175 {
13176 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
13177 ret = -10000;
13178 break;
13179 }
13180 ret = select_dropitem(ri->dropsetref) * 10000;
13181 break;
13182 }
13183
13184 ///----------------------------------------------------------------------------------------------------//
13185 //Audio Variables
13186
13187 case AUDIOVOLUME:
13188 {
13189 int32_t indx = ri->d[rINDEX] / 10000;
13190 switch(indx)
13191 {
13192
13193 case 0: //midi volume
13194 {
13195 ret = FFScript::do_getMIDI_volume() * 10000;
13196 break;
13197 }
13198 case 1: //digi volume
13199 {
13200 ret = FFScript::do_getDIGI_volume() * 10000;
13201 break;
13202 }
13203 case 2: //emh music volume
13204 {
13205 ret = FFScript::do_getMusic_volume() * 10000;
13206 break;
13207 }
13208 case 3: //sfx volume
13209 {
13210 ret = FFScript::do_getSFX_volume() * 10000;
13211 break;
13212 }
13213 default:
13214 {
13215 Z_scripterrlog("Attempted to access an invalid index of Audio->Volume[]", indx);
13216 ret = -10000;
13217 break;
13218 }
13219 }
13220 }
13221 break;
13222
13223 case AUDIOPAN:
13224 {
13225 ret = FFScript::do_getSFX_pan() * 10000;
13226 break;
13227 }
13228
13229 ///----------------------------------------------------------------------------------------------------//
13230 //Graphics->
13231
13232 case NUMDRAWS:
13233 ret = script_drawing_commands.Count() * 10000;
13234 //ret = FFCore.numscriptdraws * 10000; // This isn't updated until end of frame, making it useless!
13235 break;
13236
13237 case MAXDRAWS:
13238 ret = MAX_SCRIPT_DRAWING_COMMANDS * 10000;
13239 break;
13240
13241 case ISBLANKTILE: ret = (FFCore.IsBlankTile(ri->d[rINDEX]/10000) * 10000); break;
13242
13243 case BITMAPWIDTH:
13244 {
13245 //if ( scb.script_created_bitmaps[ri->bitmapref].u_bmp )
13246 //{
13247 // ret = scb.script_created_bitmaps[ri->bitmapref].u_bmp->w * 10000;
13248 //}
13249 //else ret = 0;
13250 ret = scb.script_created_bitmaps[ri->bitmapref-10].width * 10000;
13251 break;
13252 }
13253
13254 case BITMAPHEIGHT:
13255 {
13256 //Z_scripterrlog("BITMAPHEI|GHT ri->BitmapRef is %d\n", ri->bitmapref);
13257 //Z_scripterrlog("ref bitmap height: %d\n", scb.script_created_bitmaps[ri->bitmapref-10].u_bmp->h);
13258 //if ( scb.script_created_bitmaps[ri->bitmapref].u_bmp )
13259 //{
13260 // ret = scb.script_created_bitmaps[ri->bitmapref].u_bmp->h * 10000;
13261 //}
13262 //else ret = 0;
13263 ret = scb.script_created_bitmaps[ri->bitmapref-10].height * 10000;
13264 break;
13265 }
13266 ///----------------------------------------------------------------------------------------------------//
13267 //File->
13268 case FILEPOS:
13269 {
13270 if(user_file* f = checkFile(ri->fileref, "Pos", true))
13271 {
13272 ret = ftell(f->file); //NOT *10000 -V
13273 }
13274 else ret = -10000L;
13275 break;
13276 }
13277 case FILEEOF:
13278 {
13279 if(user_file* f = checkFile(ri->fileref, "EOF", true))
13280 {
13281 ret = feof(f->file) ? 10000L : 0L; //Boolean
13282 }
13283 else ret = -10000L;
13284 break;
13285 }
13286 case FILEERR:
13287 {
13288 if(user_file* f = checkFile(ri->fileref, "Error", true))
13289 {
13290 ret = ferror(f->file) * 10000L;
13291 }
13292 else ret = -10000L;
13293 break;
13294 }
13295
13296 ///----------------------------------------------------------------------------------------------------//
13297 //Directory->
13298 case DIRECTORYSIZE:
13299 {
13300 if(user_dir* dr = checkDir(ri->directoryref, "Size()", true))
13301 {
13302 ret = dr->size() * 10000L;
13303 }
13304 else ret = -10000L;
13305 break;
13306 }
13307
13308 ///----------------------------------------------------------------------------------------------------//
13309 //Stack->
13310 case STACKSIZE:
13311 {
13312 if(user_stack* st = checkStack(ri->stackref, "Size", true))
13313 {
13314 ret = st->size(); //NOT *10000
13315 }
13316 else ret = -10000L;
13317 break;
13318 }
13319 case STACKFULL:
13320 {
13321 if(user_stack* st = checkStack(ri->stackref, "Full", true))
13322 {
13323 ret = st->full() ? 10000L : 0L;
13324 }
13325 else ret = -10000L;
13326 break;
13327 }
13328
13329 ///----------------------------------------------------------------------------------------------------//
13330 //Module->
13331
13332 case MODULEGETINT:
13333 {
13334 int32_t section_pointer = ((ri->d[rINDEX])/10000);
13335 int32_t element_pointer = ((ri->d[rINDEX2])/10000);
13336 string sectionid;
13337 string elementid;
13338
13339 ArrayH::getString(section_pointer, sectionid);
13340 ArrayH::getString(element_pointer, elementid);
13341
13342 ///set config file
13343 if(!fileexists((char*)moduledata.module_name))
13344 {
13345 Z_scripterrlog("I/O Error: No module definitions found when using Module->GetInt()\n");
13346 ret = -10000;
13347 }
13348 else
13349 {
13350 zc_push_config();
13351 zc_config_file(moduledata.module_name);
13352 ret = zc_get_config_basic(sectionid.c_str(), elementid.c_str(), 0)*10000;
13353 //return config file to zc.cfg
13354 zc_pop_config();
13355 }
13356 break;
13357 }
13358
13359 ///----------------------------------------------------------------------------------------------------//
13360 //Misc./Internal
13361 case REFFFC:
13362 15657 ret = ri->ffcref * 10000;
13363 15657 break;
13364
13365 case REFITEM:
13366 158257 ret = ri->itemref;
13367 158257 break;
13368
13369 case REFITEMCLASS:
13370 1817944 ret = ri->idata;
13371 1817944 break;
13372
13373 case REFLWPN:
13374 1340238 ret = ri->lwpn;
13375 1340238 break;
13376
13377 case REFEWPN:
13378 2886839 ret = ri->ewpn;
13379 2886839 break;
13380
13381 case REFNPC:
13382 15646729 ret = ri->guyref;
13383 15646729 break;
13384
13385 case REFMAPDATA: ret = ri->mapsref; break;
13386 case REFSCREENDATA: ret = ri->screenref; break;
13387 25786 case REFCOMBODATA: ret = ri->combosref; break;
13388 16 case REFSPRITEDATA: ret = ri->spritesref; break;
13389 case REFBITMAP: ret = ri->bitmapref; break;
13390 case REFNPCCLASS: ret = ri->npcdataref; break;
13391
13392
13393 802600 case REFDMAPDATA: ret = ri->dmapsref; break;
13394 case REFSHOPDATA: ret = ri->shopsref; break;
13395 case REFMSGDATA: ret = ri->zmsgref; break;
13396 case REFUNTYPED: ret = ri->untypedref; break;
13397
13398 case REFDROPS: ret = ri->dropsetref; break;
13399 case REFBOTTLETYPE: ret = ri->bottletyperef; break;
13400 case REFBOTTLESHOP: ret = ri->bottleshopref; break;
13401 427 case REFGENERICDATA: ret = ri->genericdataref; break;
13402 case REFPONDS: ret = ri->pondref; break;
13403 case REFWARPRINGS: ret = ri->warpringref; break;
13404 case REFDOORS: ret = ri->doorsref; break;
13405 case REFUICOLOURS: ret = ri->zcoloursref; break;
13406 case REFRGB: ret = ri->rgbref; break;
13407 case REFPALETTE: ret = ri->paletteref; break;
13408 case REFTUNES: ret = ri->tunesref; break;
13409 case REFPALCYCLE: ret = ri->palcycleref; break;
13410 case REFGAMEDATA: ret = ri->gamedataref; break;
13411 case REFCHEATS: ret = ri->cheatsref; break;
13412 case REFFILE: ret = ri->fileref; break;
13413 case REFDIRECTORY: ret = ri->directoryref; break;
13414 case REFSTACK: ret = ri->stackref; break;
13415 case REFSUBSCREEN: ret = ri->subdataref; break;
13416 case REFSUBSCREENPAGE: ret = ri->subpageref; break;
13417 case REFSUBSCREENWIDG: ret = ri->subwidgref; break;
13418 case REFRNG: ret = ri->rngref; break;
13419 case CLASS_THISKEY: ret = ri->thiskey; break;
13420 case CLASS_THISKEY2: ret = ri->thiskey2; break;
13421 case REFPALDATA: ret = ri->paldataref; break;
13422
13423
13424 case SP:
13425 ret = ri->sp * 10000;
13426 break;
13427
13428 case PC:
13429 ret = ri->pc;
13430 break;
13431
13432 case SWITCHKEY:
13433 ret = ri->switchkey;
13434 break;
13435
13436 case SCRIPTRAM:
13437 case GLOBALRAM:
13438 952310006 ret = ArrayH::getElement(ri->d[rINDEX] / 10000, ri->d[rINDEX2] / 10000);
13439 952310006 break;
13440
13441 case SCRIPTRAMD:
13442 case GLOBALRAMD:
13443 ret = ArrayH::getElement(ri->d[rINDEX] / 10000, 0);
13444 break;
13445
13446 case GDD://Doesn't work like this =(
13447 ret = game->global_d[ri->d[rINDEX] / 10000];
13448 break;
13449
13450 ///----------------------------------------------------------------------------------------------------//
13451
13452 case PALDATACOLOR:
13453 {
13454 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->GetColor()"))
13455 {
13456 int32_t ind = ri->d[rINDEX] / 10000; // get_register(sarg1) / 10000;
13457 if (unsigned(ind) >= PALDATA_NUM_COLORS)
13458 {
13459 Z_scripterrlog("Invalid color index (%d) passed to paldata->GetColor(). Valid indices are 0-255.\n", ind);
13460 ret = -10000;
13461 break;
13462 }
13463
13464 if (get_bit(pd->colors_used, ind))
13465 {
13466 RGB c = pd->colors[ind];
13467
13468 ret = (c.r << 16) | (c.g << 8) | c.b;
13469 }
13470 else
13471 {
13472 //Z_scripterrlog("Color index (%d) returned an invalid color in paldata->GetColor().\n", ind);
13473 ret = -10000;
13474 break;
13475 }
13476 }
13477 break;
13478 }
13479 case PALDATAR:
13480 ret = FFCore.do_paldata_getrgb(0);
13481 break;
13482 case PALDATAG:
13483 ret = FFCore.do_paldata_getrgb(1);
13484 break;
13485 case PALDATAB:
13486 ret = FFCore.do_paldata_getrgb(2);
13487 break;
13488
13489 ///----------------------------------------------------------------------------------------------------//
13490
13491 case GENDATARUNNING:
13492 {
13493 ret = 0;
13494 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "Running"))
13495 {
13496 ret = scr->doscript ? 10000L : 0L;
13497 }
13498 break;
13499 }
13500 case GENDATASIZE:
13501 {
13502 ret = 0;
13503 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "DataSize"))
13504 {
13505 ret = scr->dataSize()*10000;
13506 }
13507 break;
13508 }
13509 case GENDATAEXITSTATE:
13510 {
13511 ret = 0;
13512 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "ExitState"))
13513 {
13514 size_t indx = ri->d[rINDEX]/10000;
13515 if(indx >= GENSCR_NUMST)
13516 {
13517 Z_scripterrlog("Invalid index passed to genericdata->ExitState[]: %d\n", indx);
13518 break;
13519 }
13520 ret = (scr->exitState & (1<<indx)) ? 10000L : 0;
13521 }
13522 break;
13523 }
13524 case GENDATARELOADSTATE:
13525 {
13526 ret = 0;
13527 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "ReloadState"))
13528 {
13529 size_t indx = ri->d[rINDEX]/10000;
13530 if(indx >= GENSCR_NUMST)
13531 {
13532 Z_scripterrlog("Invalid index passed to genericdata->ReloadState[]: %d\n", indx);
13533 break;
13534 }
13535 ret = (scr->reloadState & (1<<indx)) ? 10000L : 0;
13536 }
13537 break;
13538 }
13539 case GENDATAEVENTSTATE:
13540 {
13541 ret = 0;
13542 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "EventListen"))
13543 {
13544 size_t indx = ri->d[rINDEX]/10000;
13545 if(indx >= GENSCR_NUMEVENT)
13546 {
13547 Z_scripterrlog("Invalid index passed to genericdata->EventListen[]: %d\n", indx);
13548 break;
13549 }
13550 ret = (scr->eventstate & (1<<indx)) ? 10000L : 0;
13551 }
13552 break;
13553 }
13554 case GENDATADATA:
13555 {
13556 ret = 0;
13557 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "Data[]"))
13558 {
13559 size_t indx = ri->d[rINDEX]/10000;
13560 if(indx >= scr->dataSize())
13561 {
13562 Z_scripterrlog("Invalid index passed to genericdata->Data[]: %d\n", indx);
13563 break;
13564 }
13565 ret = scr->data[indx];
13566 }
13567 break;
13568 }
13569 case GENDATAINITD:
13570 {
13571 ret = 0;
13572 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "InitD[]"))
13573 {
13574 size_t indx = ri->d[rINDEX]/10000;
13575 if(indx >= 8)
13576 {
13577 Z_scripterrlog("Invalid index passed to genericdata->InitD[]: %d\n", indx);
13578 break;
13579 }
13580 ret = scr->initd[indx];
13581 }
13582 break;
13583 }
13584
13585 ///----------------------------------------------------------------------------------------------------//
13586
13587 case PORTALX:
13588 {
13589 ret = -10000;
13590 if(portal* p = checkPortal(ri->portalref, "X"))
13591 ret = p->x.getZLong();
13592 break;
13593 }
13594 case PORTALY:
13595 {
13596 ret = -10000;
13597 if(portal* p = checkPortal(ri->portalref, "Y"))
13598 ret = p->y.getZLong();
13599 break;
13600 }
13601 case PORTALDMAP:
13602 {
13603 ret = -10000;
13604 if(portal* p = checkPortal(ri->portalref, "DMap"))
13605 ret = p->destdmap*10000;
13606 break;
13607 }
13608 case PORTALSCREEN:
13609 {
13610 ret = -10000;
13611 if(portal* p = checkPortal(ri->portalref, "Screen"))
13612 ret = p->destscr*10000;
13613 break;
13614 }
13615 case PORTALACLK:
13616 {
13617 ret = -10000;
13618 if(portal* p = checkPortal(ri->portalref, "AClk"))
13619 ret = p->aclk*10000;
13620 break;
13621 }
13622 case PORTALAFRM:
13623 {
13624 ret = -10000;
13625 if(portal* p = checkPortal(ri->portalref, "AFrame"))
13626 ret = p->aframe*10000;
13627 break;
13628 }
13629 case PORTALOTILE:
13630 {
13631 ret = -10000;
13632 if(portal* p = checkPortal(ri->portalref, "OriginalTile"))
13633 ret = p->o_tile*10000;
13634 break;
13635 }
13636 case PORTALASPD:
13637 {
13638 ret = -10000;
13639 if(portal* p = checkPortal(ri->portalref, "ASpeed"))
13640 ret = p->aspd*10000;
13641 break;
13642 }
13643 case PORTALFRAMES:
13644 {
13645 ret = -10000;
13646 if(portal* p = checkPortal(ri->portalref, "Frames"))
13647 ret = p->frames*10000;
13648 break;
13649 }
13650 case PORTALSAVED:
13651 {
13652 ret = 0;
13653 if(portal* p = checkPortal(ri->portalref, "SavedPortal"))
13654 ret = p->saved_data;
13655 break;
13656 }
13657 case PORTALCLOSEDIS:
13658 {
13659 ret = 0;
13660 if(portal* p = checkPortal(ri->portalref, "CloseDisabled"))
13661 ret = p->prox_active ? 0 : 10000; //Inverted
13662 break;
13663 }
13664 case REFPORTAL:
13665 {
13666 ret = ri->portalref;
13667 break;
13668 }
13669 case REFSAVPORTAL:
13670 {
13671 ret = ri->saveportalref;
13672 break;
13673 }
13674 case PORTALWARPSFX:
13675 {
13676 ret = 0;
13677 if(portal* p = checkPortal(ri->portalref, "WarpSFX"))
13678 ret = p->wsfx ? 0 : 10000;
13679 break;
13680 }
13681 case PORTALWARPVFX:
13682 {
13683 ret = 0;
13684 if(portal* p = checkPortal(ri->portalref, "WarpEffect"))
13685 ret = p->weffect ? 0 : 10000;
13686 break;
13687 }
13688 case SAVEDPORTALX:
13689 {
13690 ret = -10000;
13691 if(savedportal* p = checkSavedPortal(ri->saveportalref, "X"))
13692 ret = p->x;
13693 break;
13694 }
13695 case SAVEDPORTALY:
13696 {
13697 ret = -10000;
13698 if(savedportal* p = checkSavedPortal(ri->saveportalref, "Y"))
13699 ret = p->y;
13700 break;
13701 }
13702 case SAVEDPORTALSRCDMAP:
13703 {
13704 ret = -10000;
13705 if(savedportal* p = checkSavedPortal(ri->saveportalref, "SrcDMap"))
13706 ret = p->srcdmap * 10000;
13707 break;
13708 }
13709 case SAVEDPORTALDESTDMAP:
13710 {
13711 ret = -10000;
13712 if(savedportal* p = checkSavedPortal(ri->saveportalref, "DestDMap"))
13713 ret = p->destdmap * 10000;
13714 break;
13715 }
13716 case SAVEDPORTALSRCSCREEN:
13717 {
13718 ret = -10000;
13719 if(savedportal* p = checkSavedPortal(ri->saveportalref, "SrcScreen"))
13720 ret = p->srcscr * 10000;
13721 break;
13722 }
13723 case SAVEDPORTALDSTSCREEN:
13724 {
13725 ret = -10000;
13726 if(savedportal* p = checkSavedPortal(ri->saveportalref, "DestScreen"))
13727 ret = p->destscr * 10000;
13728 break;
13729 }
13730 case SAVEDPORTALWARPSFX:
13731 {
13732 ret = -10000;
13733 if(savedportal* p = checkSavedPortal(ri->saveportalref, "WarpSFX"))
13734 ret = p->sfx * 10000;
13735 break;
13736 }
13737 case SAVEDPORTALWARPVFX:
13738 {
13739 ret = -10000;
13740 if(savedportal* p = checkSavedPortal(ri->saveportalref, "WarpEffect"))
13741 ret = p->warpfx * 10000;
13742 break;
13743 }
13744 case SAVEDPORTALSPRITE:
13745 {
13746 ret = -10000;
13747 if(savedportal* p = checkSavedPortal(ri->saveportalref, "Sprite"))
13748 ret = p->spr * 10000;
13749 break;
13750 }
13751 case SAVEDPORTALPORTAL:
13752 {
13753 ret = 0;
13754 if(savedportal* p = checkSavedPortal(ri->saveportalref, "Portal"))
13755 ret = getPortalFromSaved(p);
13756 break;
13757 }
13758 case PORTALCOUNT:
13759 {
13760 ret = portals.Count()*10000;
13761 break;
13762 }
13763 case SAVEDPORTALCOUNT:
13764 {
13765 ret = game->user_portals.size()*10000;
13766 break;
13767 }
13768
13769 case GAMEASUBOPEN:
13770 {
13771 ret = subscreen_open ? 10000 : 0;
13772 break;
13773 }
13774 case GAMEASUBYOFF:
13775 {
13776 ret = active_sub_yoff*10000;
13777 break;
13778 }
13779 case GAMENUMASUB:
13780 {
13781 ret = subscreens_active.size()*10000;
13782 break;
13783 }
13784 case GAMENUMPSUB:
13785 {
13786 ret = subscreens_passive.size()*10000;
13787 break;
13788 }
13789 case GAMENUMOSUB:
13790 {
13791 ret = subscreens_overlay.size()*10000;
13792 break;
13793 }
13794
13795 ///----------------------------------------------------------------------------------------------------//
13796
13797 case SUBDATACURPG:
13798 {
13799 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "CurPage"))
13800 if(sub->sub_type == sstACTIVE)
13801 ret = 10000*sub->curpage;
13802 break;
13803 }
13804 case SUBDATANUMPG:
13805 {
13806 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "NumPages"))
13807 {
13808 if(sub->sub_type == sstACTIVE)
13809 ret = 10000*sub->pages.size();
13810 else ret = 10000;
13811 }
13812 break;
13813 }
13814 case SUBDATAPAGES:
13815 {
13816 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "Pages[]"))
13817 {
13818 size_t indx = ri->d[rINDEX]/10000;
13819 size_t sz = sub->sub_type == sstACTIVE ? sub->pages.size() : 1;
13820 if(indx >= sz)
13821 {
13822 Z_scripterrlog("Bad index '%d' to array "
13823 "'subscreendata->Pages[]' of size '%d'\n", indx, sz);
13824 }
13825 else
13826 {
13827 auto [sb,ty,_pg,_ind] = from_subref(ri->subdataref);
13828 ret = get_subref(sb,ty,indx,0);
13829 }
13830 }
13831 break;
13832 }
13833 case SUBDATATYPE:
13834 {
13835 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "Type"))
13836 ret = sub->sub_type*10000;
13837 break;
13838 }
13839 case SUBDATAFLAGS:
13840 {
13841 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "Flags[]"))
13842 {
13843 size_t indx = ri->d[rINDEX]/10000;
13844 size_t sz = 0;
13845 switch(sub->sub_type)
13846 {
13847 case sstACTIVE:
13848 sz = 2;
13849 break;
13850 case sstPASSIVE:
13851 sz = 0;
13852 break;
13853 case sstOVERLAY:
13854 sz = 0;
13855 break;
13856 }
13857 if(indx >= sz)
13858 {
13859 Z_scripterrlog("Bad index '%d' to array "
13860 "'subscreendata->Flags[]' of size '%d'\n", indx, sz);
13861 }
13862 else
13863 ret = (sub->flags & (1<<indx)) ? 10000 : 0;
13864 }
13865 break;
13866 }
13867 ///---- ACTIVE SUBSCREENS ONLY
13868 case SUBDATACURSORPOS:
13869 {
13870 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "CursorPos", sstACTIVE))
13871 {
13872 SubscrPage& pg = sub->cur_page();
13873 ret = pg.cursor_pos * 10000;
13874 }
13875 break;
13876 }
13877 case SUBDATASCRIPT:
13878 {
13879 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "Script", sstACTIVE))
13880 ret = sub->script * 10000;
13881 break;
13882 }
13883 case SUBDATAINITD:
13884 {
13885 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "InitD[]", sstACTIVE))
13886 {
13887 size_t indx = ri->d[rINDEX]/10000;
13888 if(indx >= 8)
13889 {
13890 Z_scripterrlog("Bad index '%d' to array "
13891 "'subscreendata->InitD[8]'\n", indx);
13892 }
13893 else
13894 ret = sub->initd[indx];
13895 }
13896 break;
13897 }
13898 case SUBDATABTNLEFT:
13899 {
13900 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "BtnPageLeft[]", sstACTIVE))
13901 {
13902 size_t indx = ri->d[rINDEX]/10000;
13903 if(indx >= 8)
13904 {
13905 Z_scripterrlog("Bad index '%d' to array "
13906 "'subscreendata->BtnPageLeft[8]'\n", indx);
13907 }
13908 else
13909 ret = (sub->btn_left & (1<<indx)) ? 10000 : 0;
13910 }
13911 break;
13912 }
13913 case SUBDATABTNRIGHT:
13914 {
13915 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "BtnPageRight[]", sstACTIVE))
13916 {
13917 size_t indx = ri->d[rINDEX]/10000;
13918 if(indx >= 8)
13919 {
13920 Z_scripterrlog("Bad index '%d' to array "
13921 "'subscreendata->BtnPageRight[8]'\n", indx);
13922 }
13923 else
13924 ret = (sub->btn_right & (1<<indx)) ? 10000 : 0;
13925 }
13926 break;
13927 }
13928 case SUBDATATRANSLEFTTY:
13929 {
13930 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransLeftType", sstACTIVE))
13931 {
13932 auto& trans = sub->trans_left;
13933 ret = trans.type * 10000;
13934 }
13935 break;
13936 }
13937 case SUBDATATRANSLEFTSFX:
13938 {
13939 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransLeftSFX", sstACTIVE))
13940 {
13941 auto& trans = sub->trans_left;
13942 ret = trans.tr_sfx * 10000;
13943 }
13944 break;
13945 }
13946 case SUBDATATRANSLEFTFLAGS:
13947 {
13948 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransLeftFlags[]", sstACTIVE))
13949 {
13950 auto& trans = sub->trans_left;
13951 size_t indx = ri->d[rINDEX]/10000;
13952 if(indx >= SUBSCR_TRANS_NUMFLAGS)
13953 {
13954 Z_scripterrlog("Bad index '%d' to array "
13955 "'subscreendata->TransLeftFlags[%d]'\n", indx, SUBSCR_TRANS_NUMFLAGS);
13956 }
13957 else
13958 ret = (trans.flags & (1<<indx)) ? 10000 : 0;
13959 }
13960 break;
13961 }
13962 case SUBDATATRANSLEFTARGS:
13963 {
13964 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransLeftArgs[]", sstACTIVE))
13965 {
13966 auto& trans = sub->trans_left;
13967 size_t indx = ri->d[rINDEX]/10000;
13968 if(indx >= SUBSCR_TRANSITION_MAXARG)
13969 {
13970 Z_scripterrlog("Bad index '%d' to array "
13971 "'subscreendata->TransLeftArgs[%d]'\n", indx, SUBSCR_TRANSITION_MAXARG);
13972 }
13973 else
13974 ret = trans.arg[indx]*SubscrTransition::argScale(trans.type,indx);
13975 }
13976 break;
13977 }
13978 case SUBDATATRANSRIGHTTY:
13979 {
13980 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransRightType", sstACTIVE))
13981 {
13982 auto& trans = sub->trans_right;
13983 ret = trans.type * 10000;
13984 }
13985 break;
13986 }
13987 case SUBDATATRANSRIGHTSFX:
13988 {
13989 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransRightSFX", sstACTIVE))
13990 {
13991 auto& trans = sub->trans_right;
13992 ret = trans.tr_sfx * 10000;
13993 }
13994 break;
13995 }
13996 case SUBDATATRANSRIGHTFLAGS:
13997 {
13998 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransRightFlags[]", sstACTIVE))
13999 {
14000 auto& trans = sub->trans_right;
14001 size_t indx = ri->d[rINDEX]/10000;
14002 if(indx >= SUBSCR_TRANS_NUMFLAGS)
14003 {
14004 Z_scripterrlog("Bad index '%d' to array "
14005 "'subscreendata->TransRightFlags[%d]'\n", indx, SUBSCR_TRANS_NUMFLAGS);
14006 }
14007 else
14008 ret = (trans.flags & (1<<indx)) ? 10000 : 0;
14009 }
14010 break;
14011 }
14012 case SUBDATATRANSRIGHTARGS:
14013 {
14014 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransRightArgs[]", sstACTIVE))
14015 {
14016 auto& trans = sub->trans_right;
14017 size_t indx = ri->d[rINDEX]/10000;
14018 if(indx >= SUBSCR_TRANSITION_MAXARG)
14019 {
14020 Z_scripterrlog("Bad index '%d' to array "
14021 "'subscreendata->TransRightArgs[%d]'\n", indx, SUBSCR_TRANSITION_MAXARG);
14022 }
14023 else
14024 ret = trans.arg[indx]*SubscrTransition::argScale(trans.type,indx);
14025 }
14026 break;
14027 }
14028 case SUBDATASELECTORDSTX:
14029 {
14030 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestX", sstACTIVE))
14031 ret = sub->selector_setting.x * 10000;
14032 break;
14033 }
14034 case SUBDATASELECTORDSTY:
14035 {
14036 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestY", sstACTIVE))
14037 ret = sub->selector_setting.y * 10000;
14038 break;
14039 }
14040 case SUBDATASELECTORDSTW:
14041 {
14042 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestW", sstACTIVE))
14043 ret = sub->selector_setting.w * 10000;
14044 break;
14045 }
14046 case SUBDATASELECTORDSTH:
14047 {
14048 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestH", sstACTIVE))
14049 ret = sub->selector_setting.h * 10000;
14050 break;
14051 }
14052 case SUBDATASELECTORWID:
14053 {
14054 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestWid", sstACTIVE))
14055 {
14056 size_t indx = ri->d[rINDEX]/10000;
14057 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14058 {
14059 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
14060 "SelectorDestWid[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14061 }
14062 else
14063 ret = sub->selector_setting.tileinfo[indx].sw * 10000;
14064 }
14065 break;
14066 }
14067 case SUBDATASELECTORHEI:
14068 {
14069 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestHei", sstACTIVE))
14070 {
14071 size_t indx = ri->d[rINDEX]/10000;
14072 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14073 {
14074 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
14075 "SelectorDestHei[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14076 }
14077 else
14078 ret = sub->selector_setting.tileinfo[indx].sh * 10000;
14079 }
14080 break;
14081 }
14082 case SUBDATASELECTORTILE:
14083 {
14084 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorTile", sstACTIVE))
14085 {
14086 size_t indx = ri->d[rINDEX]/10000;
14087 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14088 {
14089 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
14090 "SelectorTile[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14091 }
14092 else
14093 ret = sub->selector_setting.tileinfo[indx].tile * 10000;
14094 }
14095 break;
14096 }
14097 case SUBDATASELECTORCSET:
14098 {
14099 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorCSet", sstACTIVE))
14100 {
14101 size_t indx = ri->d[rINDEX]/10000;
14102 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14103 {
14104 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
14105 "SelectorCSet[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14106 }
14107 else
14108 {
14109 byte& cs = sub->selector_setting.tileinfo[indx].cset;
14110 ret = (cs&0x0F) * 10000;
14111 }
14112 }
14113 break;
14114 }
14115 case SUBDATASELECTORFLASHCSET:
14116 {
14117 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorFlashCSet", sstACTIVE))
14118 {
14119 size_t indx = ri->d[rINDEX]/10000;
14120 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14121 {
14122 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
14123 "SelectorFlashCSet[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14124 }
14125 else
14126 {
14127 byte& cs = sub->selector_setting.tileinfo[indx].cset;
14128 ret = ((cs&0xF0)>>4) * 10000;
14129 }
14130 }
14131 break;
14132 }
14133 case SUBDATASELECTORFRM:
14134 {
14135 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorFrames", sstACTIVE))
14136 {
14137 size_t indx = ri->d[rINDEX]/10000;
14138 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14139 {
14140 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
14141 "SelectorFrames[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14142 }
14143 else
14144 ret = sub->selector_setting.tileinfo[indx].frames * 10000;
14145 }
14146 break;
14147 }
14148 case SUBDATASELECTORASPD:
14149 {
14150 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorASpeed", sstACTIVE))
14151 {
14152 size_t indx = ri->d[rINDEX]/10000;
14153 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14154 {
14155 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
14156 "SelectorASpeed[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14157 }
14158 else
14159 ret = sub->selector_setting.tileinfo[indx].speed * 10000;
14160 }
14161 break;
14162 }
14163 case SUBDATASELECTORDELAY:
14164 {
14165 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDelay", sstACTIVE))
14166 {
14167 size_t indx = ri->d[rINDEX]/10000;
14168 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14169 {
14170 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
14171 "SelectorDelay[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14172 }
14173 else
14174 ret = sub->selector_setting.tileinfo[indx].delay * 10000;
14175 }
14176 break;
14177 }
14178 ///---- CURRENTLY OPEN ACTIVE SUBSCREEN ONLY
14179 case SUBDATATRANSCLK:
14180 {
14181 ret = -10000;
14182 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransClock", sstACTIVE))
14183 {
14184 if(sub != new_subscreen_active)
14185 Z_scripterrlog("'subscreendata->TransClock' is only"
14186 " valid for the current active subscreen!\n");
14187 else if(subscreen_open && subscr_pg_animating)
14188 ret = subscr_pg_clk*10000;
14189 }
14190 break;
14191 }
14192 case SUBDATATRANSTY:
14193 {
14194 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransType", sstACTIVE))
14195 {
14196 auto& trans = subscr_pg_transition;
14197 if(sub != new_subscreen_active)
14198 Z_scripterrlog("'subscreendata->TransType' is only"
14199 " valid for the current active subscreen!\n");
14200 else if(subscreen_open)
14201 ret = trans.type*10000;
14202 }
14203 break;
14204 }
14205 case SUBDATATRANSFLAGS:
14206 {
14207 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransFlags[]", sstACTIVE))
14208 {
14209 auto& trans = subscr_pg_transition;
14210 size_t indx = ri->d[rINDEX]/10000;
14211 if(indx >= SUBSCR_TRANS_NUMFLAGS)
14212 {
14213 Z_scripterrlog("Bad index '%d' to array "
14214 "'subscreendata->TransFlags[%d]'\n", indx, SUBSCR_TRANS_NUMFLAGS);
14215 }
14216 else if(sub != new_subscreen_active)
14217 Z_scripterrlog("'subscreendata->TransType' is only"
14218 " valid for the current active subscreen!\n");
14219 else if(subscreen_open)
14220 ret = (trans.flags & (1<<indx)) ? 10000 : 0;
14221 }
14222 break;
14223 }
14224 case SUBDATATRANSARGS:
14225 {
14226 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransArgs[]", sstACTIVE))
14227 {
14228 auto& trans = subscr_pg_transition;
14229 size_t indx = ri->d[rINDEX]/10000;
14230 if(indx >= SUBSCR_TRANSITION_MAXARG)
14231 {
14232 Z_scripterrlog("Bad index '%d' to array "
14233 "'subscreendata->TransArgs[%d]'\n", indx, SUBSCR_TRANSITION_MAXARG);
14234 }
14235 else if(sub != new_subscreen_active)
14236 Z_scripterrlog("'subscreendata->TransType' is only"
14237 " valid for the current active subscreen!\n");
14238 else if(subscreen_open)
14239 ret = trans.arg[indx]*SubscrTransition::argScale(trans.type,indx);
14240 }
14241 break;
14242 }
14243 case SUBDATATRANSFROMPG:
14244 {
14245 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransFromPage", sstACTIVE))
14246 {
14247 if(sub != new_subscreen_active)
14248 Z_scripterrlog("'subscreendata->TransFromPage' is only"
14249 " valid for the current active subscreen!\n");
14250 else if(subscreen_open)
14251 ret = subscr_pg_from*10000;
14252 }
14253 break;
14254 }
14255 case SUBDATATRANSTOPG:
14256 {
14257 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransToPage", sstACTIVE))
14258 {
14259 if(sub != new_subscreen_active)
14260 Z_scripterrlog("'subscreendata->TransToPage' is only"
14261 " valid for the current active subscreen!\n");
14262 else if(subscreen_open)
14263 ret = subscr_pg_to*10000;
14264 }
14265 break;
14266 }
14267
14268 ///----------------------------------------------------------------------------------------------------//
14269 case SUBPGINDEX:
14270 {
14271 if(SubscrPage* pg = checkSubPage(ri->subpageref, "Index"))
14272 ret = pg->getIndex() * 10000;
14273 break;
14274 }
14275 case SUBPGNUMWIDG:
14276 {
14277 if(SubscrPage* pg = checkSubPage(ri->subpageref, "NumWidgets"))
14278 ret = pg->size() * 10000;
14279 break;
14280 }
14281 case SUBPGWIDGETS:
14282 {
14283 if(SubscrPage* pg = checkSubPage(ri->subpageref, "Widgets[]"))
14284 {
14285 size_t indx = ri->d[rINDEX]/10000;
14286 size_t sz = pg->size();
14287 if(indx >= sz)
14288 {
14289 Z_scripterrlog("Bad index '%d' to array "
14290 "'subscreenpage->Widgets[]' of size '%d'\n", indx, sz);
14291 }
14292 else
14293 {
14294 auto [sb,ty,pg,_ind] = from_subref(ri->subpageref);
14295 ret = get_subref(sb,ty,pg,indx);
14296 }
14297 }
14298 break;
14299 }
14300 case SUBPGSUBDATA:
14301 {
14302 if(SubscrPage* pg = checkSubPage(ri->subpageref, "SubData"))
14303 {
14304 auto [sub,ty,_pgid,_ind] = from_subref(ri->subpageref);
14305 ret = get_subref(sub,ty,0,0);
14306 }
14307 break;
14308 }
14309 case SUBPGCURSORPOS:
14310 {
14311 if(SubscrPage* pg = checkSubPage(ri->subpageref, "CursorPos"))
14312 ret = pg->cursor_pos * 10000;
14313 break;
14314 }
14315 ///----------------------------------------------------------------------------------------------------//
14316 ///---- ANY WIDGET TYPE
14317 case SUBWIDGTYPE:
14318 {
14319 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Type"))
14320 ret = 10000*widg->getType();
14321 break;
14322 }
14323 case SUBWIDGINDEX:
14324 {
14325 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Index"))
14326 {
14327 auto [_sub,_ty,_pgid,ind] = from_subref(ri->subwidgref);
14328 ret = 10000*ind;
14329 }
14330 break;
14331 }
14332 case SUBWIDGDISPITM:
14333 {
14334 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "DisplayItem"))
14335 {
14336 ret = 10000*widg->getDisplayItem();
14337 }
14338 break;
14339 }
14340 case SUBWIDGEQPITM:
14341 {
14342 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "EquipItem"))
14343 {
14344 ret = 10000*widg->getItemVal();
14345 }
14346 break;
14347 }
14348 case SUBWIDGPAGE:
14349 {
14350 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Page"))
14351 {
14352 auto [sub,ty,pgid,_ind] = from_subref(ri->subwidgref);
14353 ret = get_subref(sub,ty,pgid,0);
14354 }
14355 break;
14356 }
14357 case SUBWIDGPOS:
14358 {
14359 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Pos"))
14360 ret = 10000*widg->pos;
14361 break;
14362 }
14363 case SUBWIDGPOSES:
14364 {
14365 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PosDirs"))
14366 {
14367 size_t indx = ri->d[rINDEX]/10000;
14368 if(indx >= 4)
14369 {
14370 Z_scripterrlog("Bad index '%d' to array "
14371 "'subscreenwidget->PosDirs[%d]'\n", indx, 4);
14372 ret = -10000;
14373 }
14374 else
14375 {
14376 switch(indx)
14377 {
14378 case up:
14379 ret = 10000*widg->pos_up;
14380 break;
14381 case down:
14382 ret = 10000*widg->pos_down;
14383 break;
14384 case left:
14385 ret = 10000*widg->pos_left;
14386 break;
14387 case right:
14388 ret = 10000*widg->pos_right;
14389 break;
14390 }
14391 }
14392 }
14393 break;
14394 }
14395 case SUBWIDGPOSFLAG:
14396 {
14397 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "VisibleFlags"))
14398 {
14399 size_t indx = ri->d[rINDEX]/10000;
14400 if(indx >= sspNUM)
14401 {
14402 Z_scripterrlog("Bad index '%d' to array "
14403 "'subscreenwidget->VisibleFlags[%d]'\n", indx, sspNUM);
14404 }
14405 else ret = (widg->posflags & (1<<indx)) ? 10000 : 0;
14406 }
14407 break;
14408 }
14409 case SUBWIDGX:
14410 {
14411 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "X"))
14412 ret = 10000*widg->x;
14413 break;
14414 }
14415 case SUBWIDGY:
14416 {
14417 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Y"))
14418 ret = 10000*widg->y;
14419 break;
14420 }
14421 case SUBWIDGW:
14422 {
14423 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "W"))
14424 ret = 10000*widg->w;
14425 break;
14426 }
14427 case SUBWIDGH:
14428 {
14429 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "H"))
14430 ret = 10000*widg->h;
14431 break;
14432 }
14433 case SUBWIDG_DISPX:
14434 {
14435 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "X"))
14436 ret = 10000*widg->getX();
14437 break;
14438 }
14439 case SUBWIDG_DISPY:
14440 {
14441 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Y"))
14442 ret = 10000*widg->getY();
14443 break;
14444 }
14445 case SUBWIDG_DISPW:
14446 {
14447 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "W"))
14448 ret = 10000*widg->getW();
14449 break;
14450 }
14451 case SUBWIDG_DISPH:
14452 {
14453 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "H"))
14454 ret = 10000*widg->getH();
14455 break;
14456 }
14457 case SUBWIDGGENFLAG:
14458 {
14459 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GenFlags"))
14460 {
14461 size_t indx = ri->d[rINDEX]/10000;
14462 if(indx >= SUBSCRFLAG_GEN_COUNT)
14463 {
14464 Z_scripterrlog("Bad index '%d' to array "
14465 "'subscreenwidget->GenFlags[%d]'\n", indx, SUBSCRFLAG_GEN_COUNT);
14466 }
14467 else ret = (widg->genflags & (1<<indx)) ? 10000 : 0;
14468 }
14469 break;
14470 }
14471 case SUBWIDGFLAG:
14472 {
14473 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Flags"))
14474 {
14475 size_t indx = ri->d[rINDEX]/10000;
14476 byte sz = widg->numFlags();
14477 if(indx >= sz)
14478 {
14479 Z_scripterrlog("Bad index '%d' to array "
14480 "'subscreenwidget->Flags[%d]'\n", indx, sz);
14481 }
14482 else ret = (widg->flags & (1<<indx)) ? 10000 : 0;
14483 }
14484 break;
14485 }
14486 ///---- ACTIVE SUBSCREENS ONLY
14487 case SUBWIDGSELECTORDSTX:
14488 {
14489 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestX", sstACTIVE))
14490 ret = 10000*widg->selector_override.x;
14491 break;
14492 }
14493 case SUBWIDGSELECTORDSTY:
14494 {
14495 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestY", sstACTIVE))
14496 ret = 10000*widg->selector_override.y;
14497 break;
14498 }
14499 case SUBWIDGSELECTORDSTW:
14500 {
14501 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestW", sstACTIVE))
14502 ret = 10000*widg->selector_override.w;
14503 break;
14504 }
14505 case SUBWIDGSELECTORDSTH:
14506 {
14507 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestH", sstACTIVE))
14508 ret = 10000*widg->selector_override.h;
14509 break;
14510 }
14511 case SUBWIDGSELECTORWID:
14512 {
14513 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestWid", sstACTIVE))
14514 {
14515 size_t indx = ri->d[rINDEX]/10000;
14516 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14517 {
14518 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
14519 "SelectorDestWid[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14520 }
14521 else ret = 10000*widg->selector_override.tileinfo[indx].sw;
14522 }
14523 break;
14524 }
14525 case SUBWIDGSELECTORHEI:
14526 {
14527 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestHei", sstACTIVE))
14528 {
14529 size_t indx = ri->d[rINDEX]/10000;
14530 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14531 {
14532 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
14533 "SelectorDestHei[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14534 }
14535 else ret = 10000*widg->selector_override.tileinfo[indx].sh;
14536 }
14537 break;
14538 }
14539 case SUBWIDGSELECTORTILE:
14540 {
14541 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorTile", sstACTIVE))
14542 {
14543 size_t indx = ri->d[rINDEX]/10000;
14544 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14545 {
14546 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
14547 "SelectorTile[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14548 }
14549 else ret = 10000*widg->selector_override.tileinfo[indx].tile;
14550 }
14551 break;
14552 }
14553 case SUBWIDGSELECTORCSET:
14554 {
14555 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorCSet", sstACTIVE))
14556 {
14557 size_t indx = ri->d[rINDEX]/10000;
14558 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14559 {
14560 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
14561 "SelectorCSet[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14562 }
14563 else ret = 10000*(widg->selector_override.tileinfo[indx].cset&0xF);
14564 }
14565 break;
14566 }
14567 case SUBWIDGSELECTORFLASHCSET:
14568 {
14569 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorFlashCSet", sstACTIVE))
14570 {
14571 size_t indx = ri->d[rINDEX]/10000;
14572 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14573 {
14574 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
14575 "SelectorFlashCSet[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14576 }
14577 else ret = 10000*((widg->selector_override.tileinfo[indx].cset&0xF0)>>4);
14578 }
14579 break;
14580 }
14581 case SUBWIDGSELECTORFRM:
14582 {
14583 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorFrames", sstACTIVE))
14584 {
14585 size_t indx = ri->d[rINDEX]/10000;
14586 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14587 {
14588 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
14589 "SelectorFrames[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14590 }
14591 else ret = 10000*widg->selector_override.tileinfo[indx].frames;
14592 }
14593 break;
14594 }
14595 case SUBWIDGSELECTORASPD:
14596 {
14597 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorASpeed", sstACTIVE))
14598 {
14599 size_t indx = ri->d[rINDEX]/10000;
14600 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14601 {
14602 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
14603 "SelectorASpeed[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14604 }
14605 else ret = 10000*widg->selector_override.tileinfo[indx].speed;
14606 }
14607 break;
14608 }
14609 case SUBWIDGSELECTORDELAY:
14610 {
14611 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDelay", sstACTIVE))
14612 {
14613 size_t indx = ri->d[rINDEX]/10000;
14614 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
14615 {
14616 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
14617 "SelectorDelay[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
14618 }
14619 else ret = 10000*widg->selector_override.tileinfo[indx].delay;
14620 }
14621 break;
14622 }
14623
14624 case SUBWIDGPRESSSCRIPT:
14625 {
14626 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PressScript", sstACTIVE))
14627 ret = 10000*widg->generic_script;
14628 break;
14629 }
14630 case SUBWIDGPRESSINITD:
14631 {
14632 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PressInitD[]", sstACTIVE))
14633 {
14634 size_t indx = ri->d[rINDEX]/10000;
14635 if(indx >= 8)
14636 {
14637 Z_scripterrlog("Bad index '%d' to array "
14638 "'subscreenwidget->PressInitD[8]'\n", indx);
14639 }
14640 else ret = widg->generic_initd[indx];
14641 }
14642 break;
14643 }
14644 case SUBWIDGBTNPRESS:
14645 {
14646 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "BtnPressScript[]", sstACTIVE))
14647 {
14648 size_t indx = ri->d[rINDEX]/10000;
14649 if(indx >= 8)
14650 {
14651 Z_scripterrlog("Bad index '%d' to array "
14652 "'subscreenwidget->BtnPressScript[8]'\n", indx);
14653 }
14654 else ret = (widg->gen_script_btns & (1<<indx)) ? 10000 : 0;
14655 }
14656 break;
14657 }
14658 case SUBWIDGBTNPG:
14659 {
14660 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "BtnPageChange[]", sstACTIVE))
14661 {
14662 size_t indx = ri->d[rINDEX]/10000;
14663 if(indx >= 8)
14664 {
14665 Z_scripterrlog("Bad index '%d' to array "
14666 "'subscreenwidget->BtnPageChange[8]'\n", indx);
14667 }
14668 else ret = (widg->pg_btns & (1<<indx)) ? 10000 : 0;
14669 }
14670 break;
14671 }
14672 case SUBWIDGPGMODE:
14673 {
14674 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PageMode", sstACTIVE))
14675 ret = 10000*widg->pg_mode;
14676 break;
14677 }
14678 case SUBWIDGPGTARG:
14679 {
14680 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "TargetPage", sstACTIVE))
14681 ret = 10000*widg->pg_targ;
14682 break;
14683 }
14684
14685 case SUBWIDGTRANSPGTY:
14686 {
14687 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PageTransType", sstACTIVE))
14688 {
14689 auto& trans = widg->pg_trans;
14690 ret = 10000*trans.type;
14691 }
14692 break;
14693 }
14694 case SUBWIDGTRANSPGSFX:
14695 {
14696 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PageTransSFX", sstACTIVE))
14697 {
14698 auto& trans = widg->pg_trans;
14699 ret = 10000*trans.tr_sfx;
14700 }
14701 break;
14702 }
14703 case SUBWIDGTRANSPGFLAGS:
14704 {
14705 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PageTransFlags[]", sstACTIVE))
14706 {
14707 auto& trans = widg->pg_trans;
14708 size_t indx = ri->d[rINDEX]/10000;
14709 if(indx >= SUBSCR_TRANS_NUMFLAGS)
14710 {
14711 Z_scripterrlog("Bad index '%d' to array "
14712 "'subscreenwidget->PageTransFlags[%d]'\n", indx, SUBSCR_TRANS_NUMFLAGS);
14713 }
14714 else ret = (trans.flags & (1<<indx)) ? 10000 : 0;
14715 }
14716 break;
14717 }
14718 case SUBWIDGTRANSPGARGS:
14719 {
14720 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PageTransArgs[]", sstACTIVE))
14721 {
14722 auto& trans = widg->pg_trans;
14723 size_t indx = ri->d[rINDEX]/10000;
14724 if(indx >= SUBSCR_TRANSITION_MAXARG)
14725 {
14726 Z_scripterrlog("Bad index '%d' to array "
14727 "'subscreenwidget->PageTransArgs[%d]'\n", indx, SUBSCR_TRANSITION_MAXARG);
14728 }
14729 else ret = trans.arg[indx]*SubscrTransition::argScale(trans.type,indx);
14730 }
14731 break;
14732 }
14733 ///---- VARYING WIDGET TYPES
14734 case SUBWIDGTY_CSET:
14735 {
14736 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "CSet[]"))
14737 {
14738 size_t indx = ri->d[rINDEX]/10000;
14739 size_t sz = 0;
14740 byte ty = widg->getType();
14741 switch(ty)
14742 {
14743 case widgFRAME:
14744 case widgMCGUFF:
14745 case widgTILEBLOCK:
14746 case widgMINITILE:
14747 sz = 1;
14748 break;
14749 case widgLGAUGE:
14750 case widgMGAUGE:
14751 case widgMISCGAUGE:
14752 sz = 4;
14753 break;
14754 default:
14755 sz = 0;
14756 bad_subwidg_type("CSet[]", false, ty);
14757 ret = -10000;
14758 break;
14759 }
14760 if(!sz) break;
14761 if(indx >= sz)
14762 {
14763 Z_scripterrlog("Bad index '%d' to array "
14764 "'subscreenwidget->CSet[%d]'\n", indx, sz);
14765 break;
14766 }
14767 switch(ty)
14768 {
14769 case widgFRAME:
14770 ret = ((SW_2x2Frame*)widg)->cs.get_cset()*10000;
14771 break;
14772 case widgMCGUFF:
14773 ret = ((SW_McGuffin*)widg)->cs.get_cset()*10000;
14774 break;
14775 case widgTILEBLOCK:
14776 ret = ((SW_TileBlock*)widg)->cs.get_cset()*10000;
14777 break;
14778 case widgMINITILE:
14779 ret = ((SW_MiniTile*)widg)->cs.get_cset()*10000;
14780 break;
14781 case widgLGAUGE:
14782 case widgMGAUGE:
14783 case widgMISCGAUGE:
14784 ret = 10000*((SW_GaugePiece*)widg)->mts[indx].cset;
14785 break;
14786 }
14787 }
14788 break;
14789 }
14790 case SUBWIDGTY_TILE:
14791 {
14792 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Tile"))
14793 {
14794 size_t indx = ri->d[rINDEX]/10000;
14795 size_t sz = 0;
14796 byte ty = widg->getType();
14797 switch(ty)
14798 {
14799 case widgFRAME:
14800 case widgMCGUFF:
14801 case widgTILEBLOCK:
14802 case widgMINITILE:
14803 sz = 1;
14804 break;
14805 case widgLGAUGE:
14806 case widgMGAUGE:
14807 case widgMISCGAUGE:
14808 sz = 4;
14809 break;
14810 default:
14811 sz = 0;
14812 bad_subwidg_type("Tile[]", false, ty);
14813 ret = -10000;
14814 break;
14815 }
14816 if(!sz) break;
14817 if(indx >= sz)
14818 {
14819 Z_scripterrlog("Bad index '%d' to array "
14820 "'subscreenwidget->Tile[%d]'\n", indx, sz);
14821 break;
14822 }
14823 switch(ty)
14824 {
14825 case widgFRAME:
14826 ret = ret = 10000*((SW_2x2Frame*)widg)->tile;
14827 break;
14828 case widgMCGUFF:
14829 ret = 10000*((SW_McGuffin*)widg)->tile;
14830 break;
14831 case widgTILEBLOCK:
14832 ret = 10000*((SW_TileBlock*)widg)->tile;
14833 break;
14834 case widgMINITILE:
14835 ret = 10000*((SW_MiniTile*)widg)->get_int_tile();
14836 break;
14837 case widgLGAUGE:
14838 case widgMGAUGE:
14839 case widgMISCGAUGE:
14840 ret = 10000*((SW_GaugePiece*)widg)->mts[indx].tile();
14841 break;
14842 }
14843 }
14844 break;
14845 }
14846 case SUBWIDGTY_FONT:
14847 {
14848 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Font"))
14849 {
14850 auto ty = widg->getType();
14851 switch(ty)
14852 {
14853 case widgTEXT:
14854 ret = 10000*((SW_Text*)widg)->fontid;
14855 break;
14856 case widgTEXTBOX:
14857 ret = 10000*((SW_TextBox*)widg)->fontid;
14858 break;
14859 case widgSELECTEDTEXT:
14860 ret = 10000*((SW_SelectedText*)widg)->fontid;
14861 break;
14862 case widgTIME:
14863 ret = 10000*((SW_Time*)widg)->fontid;
14864 break;
14865 case widgCOUNTER:
14866 ret = 10000*((SW_Counter*)widg)->fontid;
14867 break;
14868 case widgBTNCOUNTER:
14869 ret = 10000*((SW_BtnCounter*)widg)->fontid;
14870 break;
14871 case widgOLDCTR:
14872 ret = 10000*((SW_Counters*)widg)->fontid;
14873 break;
14874 case widgMMAPTITLE:
14875 ret = 10000*((SW_MMapTitle*)widg)->fontid;
14876 break;
14877 default:
14878 bad_subwidg_type("Font", false, ty);
14879 ret = -10000;
14880 break;
14881 }
14882 }
14883 break;
14884 }
14885 case SUBWIDGTY_ALIGN:
14886 {
14887 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Align"))
14888 {
14889 auto ty = widg->getType();
14890 switch(ty)
14891 {
14892 case widgTEXT:
14893 ret = 10000*((SW_Text*)widg)->align;
14894 break;
14895 case widgTEXTBOX:
14896 ret = 10000*((SW_TextBox*)widg)->align;
14897 break;
14898 case widgSELECTEDTEXT:
14899 ret = 10000*((SW_SelectedText*)widg)->align;
14900 break;
14901 case widgTIME:
14902 ret = 10000*((SW_Time*)widg)->align;
14903 break;
14904 case widgCOUNTER:
14905 ret = 10000*((SW_Counter*)widg)->align;
14906 break;
14907 case widgBTNCOUNTER:
14908 ret = 10000*((SW_BtnCounter*)widg)->align;
14909 break;
14910 case widgMMAPTITLE:
14911 ret = 10000*((SW_MMapTitle*)widg)->align;
14912 break;
14913 default:
14914 bad_subwidg_type("Align", false, ty);
14915 ret = -10000;
14916 break;
14917 }
14918 }
14919 break;
14920 }
14921 case SUBWIDGTY_SHADOWTY:
14922 {
14923 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ShadowType"))
14924 {
14925 auto ty = widg->getType();
14926 switch(ty)
14927 {
14928 case widgTEXT:
14929 ret = 10000*((SW_Text*)widg)->shadtype;
14930 break;
14931 case widgTEXTBOX:
14932 ret = 10000*((SW_TextBox*)widg)->shadtype;
14933 break;
14934 case widgSELECTEDTEXT:
14935 ret = 10000*((SW_SelectedText*)widg)->shadtype;
14936 break;
14937 case widgTIME:
14938 ret = 10000*((SW_Time*)widg)->shadtype;
14939 break;
14940 case widgCOUNTER:
14941 ret = 10000*((SW_Counter*)widg)->shadtype;
14942 break;
14943 case widgBTNCOUNTER:
14944 ret = 10000*((SW_BtnCounter*)widg)->shadtype;
14945 break;
14946 case widgOLDCTR:
14947 ret = 10000*((SW_Counters*)widg)->shadtype;
14948 break;
14949 case widgMMAPTITLE:
14950 ret = 10000*((SW_MMapTitle*)widg)->shadtype;
14951 break;
14952 default:
14953 bad_subwidg_type("ShadowType", false, ty);
14954 ret = -10000;
14955 break;
14956 }
14957 }
14958 break;
14959 }
14960 case SUBWIDGTY_COLOR_TXT:
14961 {
14962 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorText"))
14963 {
14964 auto ty = widg->getType();
14965 switch(ty)
14966 {
14967 case widgTEXT:
14968 ret = 10000*((SW_Text*)widg)->c_text.get_int_color();
14969 break;
14970 case widgTEXTBOX:
14971 ret = 10000*((SW_TextBox*)widg)->c_text.get_int_color();
14972 break;
14973 case widgSELECTEDTEXT:
14974 ret = 10000*((SW_SelectedText*)widg)->c_text.get_int_color();
14975 break;
14976 case widgTIME:
14977 ret = 10000*((SW_Time*)widg)->c_text.get_int_color();
14978 break;
14979 case widgCOUNTER:
14980 ret = 10000*((SW_Counter*)widg)->c_text.get_int_color();
14981 break;
14982 case widgBTNCOUNTER:
14983 ret = 10000*((SW_BtnCounter*)widg)->c_text.get_int_color();
14984 break;
14985 case widgOLDCTR:
14986 ret = 10000*((SW_Counters*)widg)->c_text.get_int_color();
14987 break;
14988 case widgMMAPTITLE:
14989 ret = 10000*((SW_MMapTitle*)widg)->c_text.get_int_color();
14990 break;
14991 case widgMCGUFF_FRAME:
14992 ret = 10000*((SW_TriFrame*)widg)->c_number.get_int_color();
14993 break;
14994 default:
14995 bad_subwidg_type("ColorText", false, ty);
14996 break;
14997 }
14998 }
14999 break;
15000 }
15001 case SUBWIDGTY_COLOR_SHD:
15002 {
15003 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorShadow"))
15004 {
15005 auto ty = widg->getType();
15006 switch(ty)
15007 {
15008 case widgTEXT:
15009 ret = 10000*((SW_Text*)widg)->c_shadow.get_int_color();
15010 break;
15011 case widgTEXTBOX:
15012 ret = 10000*((SW_TextBox*)widg)->c_shadow.get_int_color();
15013 break;
15014 case widgSELECTEDTEXT:
15015 ret = 10000*((SW_SelectedText*)widg)->c_shadow.get_int_color();
15016 break;
15017 case widgTIME:
15018 ret = 10000*((SW_Time*)widg)->c_shadow.get_int_color();
15019 break;
15020 case widgCOUNTER:
15021 ret = 10000*((SW_Counter*)widg)->c_shadow.get_int_color();
15022 break;
15023 case widgBTNCOUNTER:
15024 ret = 10000*((SW_BtnCounter*)widg)->c_shadow.get_int_color();
15025 break;
15026 case widgOLDCTR:
15027 ret = 10000*((SW_Counters*)widg)->c_shadow.get_int_color();
15028 break;
15029 case widgMMAPTITLE:
15030 ret = 10000*((SW_MMapTitle*)widg)->c_shadow.get_int_color();
15031 break;
15032 default:
15033 bad_subwidg_type("ColorShadow", false, ty);
15034 break;
15035 }
15036 }
15037 break;
15038 }
15039 case SUBWIDGTY_COLOR_BG:
15040 {
15041 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorBG"))
15042 {
15043 auto ty = widg->getType();
15044 switch(ty)
15045 {
15046 case widgTEXT:
15047 ret = 10000*((SW_Text*)widg)->c_bg.get_int_color();
15048 break;
15049 case widgTEXTBOX:
15050 ret = 10000*((SW_TextBox*)widg)->c_bg.get_int_color();
15051 break;
15052 case widgSELECTEDTEXT:
15053 ret = 10000*((SW_SelectedText*)widg)->c_bg.get_int_color();
15054 break;
15055 case widgTIME:
15056 ret = 10000*((SW_Time*)widg)->c_bg.get_int_color();
15057 break;
15058 case widgCOUNTER:
15059 ret = 10000*((SW_Counter*)widg)->c_bg.get_int_color();
15060 break;
15061 case widgBTNCOUNTER:
15062 ret = 10000*((SW_BtnCounter*)widg)->c_bg.get_int_color();
15063 break;
15064 case widgOLDCTR:
15065 ret = 10000*((SW_Counters*)widg)->c_bg.get_int_color();
15066 break;
15067 case widgMMAPTITLE:
15068 ret = 10000*((SW_MMapTitle*)widg)->c_bg.get_int_color();
15069 break;
15070 case widgBGCOLOR:
15071 ret = 10000*((SW_Clear*)widg)->c_bg.get_int_color();
15072 break;
15073 default:
15074 bad_subwidg_type("ColorBG", false, ty);
15075 break;
15076 }
15077 }
15078 break;
15079 }
15080 case SUBWIDGTY_COLOR_OLINE:
15081 {
15082 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorOutline"))
15083 {
15084 auto ty = widg->getType();
15085 switch(ty)
15086 {
15087 case widgLINE:
15088 ret = 10000*((SW_Line*)widg)->c_line.get_int_color();
15089 break;
15090 case widgRECT:
15091 ret = 10000*((SW_Rect*)widg)->c_outline.get_int_color();
15092 break;
15093 case widgMCGUFF_FRAME:
15094 ret = 10000*((SW_TriFrame*)widg)->c_outline.get_int_color();
15095 break;
15096 default:
15097 bad_subwidg_type("ColorOutline", false, ty);
15098 break;
15099 }
15100 }
15101 break;
15102 }
15103 case SUBWIDGTY_COLOR_FILL:
15104 {
15105 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorFill"))
15106 {
15107 auto ty = widg->getType();
15108 switch(ty)
15109 {
15110 case widgRECT:
15111 ret = 10000*((SW_Rect*)widg)->c_fill.get_int_color();
15112 break;
15113 default:
15114 bad_subwidg_type("ColorFill", false, ty);
15115 break;
15116 }
15117 }
15118 break;
15119 }
15120 case SUBWIDGTY_BUTTON:
15121 {
15122 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Button"))
15123 {
15124 auto ty = widg->getType();
15125 switch(ty)
15126 {
15127 case widgBTNITM:
15128 ret = 10000*((SW_ButtonItem*)widg)->btn;
15129 break;
15130 case widgBTNCOUNTER:
15131 ret = 10000*((SW_BtnCounter*)widg)->btn;
15132 break;
15133 default:
15134 bad_subwidg_type("Button", false, ty);
15135 ret = -10000;
15136 break;
15137 }
15138 }
15139 break;
15140 }
15141 case SUBWIDGTY_COUNTERS:
15142 {
15143 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Counter[]"))
15144 {
15145 size_t indx = ri->d[rINDEX]/10000;
15146 size_t sz = 0;
15147 byte ty = widg->getType();
15148 switch(ty)
15149 {
15150 case widgCOUNTER:
15151 sz = 3;
15152 break;
15153 case widgMISCGAUGE:
15154 sz = 1;
15155 break;
15156 default:
15157 sz = 0;
15158 bad_subwidg_type("Counter[]", false, ty);
15159 ret = -10000;
15160 break;
15161 }
15162 if(!sz) break;
15163 if(indx >= sz)
15164 {
15165 Z_scripterrlog("Bad index '%d' to array "
15166 "'subscreenwidget->Counter[%d]'\n", indx, sz);
15167 break;
15168 }
15169 switch(ty)
15170 {
15171 case widgCOUNTER:
15172 ret = ((SW_Counter*)widg)->ctrs[indx]*10000;
15173 break;
15174 case widgMISCGAUGE:
15175 ret = ((SW_MiscGaugePiece*)widg)->counter*10000;
15176 break;
15177 }
15178 }
15179 break;
15180 }
15181 case SUBWIDGTY_MINDIG:
15182 {
15183 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "MinDigits"))
15184 {
15185 auto ty = widg->getType();
15186 switch(ty)
15187 {
15188 case widgCOUNTER:
15189 ret = 10000*((SW_Counter*)widg)->mindigits;
15190 break;
15191 case widgBTNCOUNTER:
15192 ret = 10000*((SW_BtnCounter*)widg)->mindigits;
15193 break;
15194 case widgOLDCTR:
15195 ret = 10000*((SW_Counters*)widg)->digits;
15196 break;
15197 default:
15198 bad_subwidg_type("MinDigits", false, ty);
15199 ret = -10000;
15200 break;
15201 }
15202 }
15203 break;
15204 }
15205 case SUBWIDGTY_MAXDIG:
15206 {
15207 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "MaxDigits"))
15208 {
15209 auto ty = widg->getType();
15210 switch(ty)
15211 {
15212 case widgCOUNTER:
15213 ret = 10000*((SW_Counter*)widg)->maxdigits;
15214 break;
15215 case widgBTNCOUNTER:
15216 ret = 10000*((SW_BtnCounter*)widg)->maxdigits;
15217 break;
15218 default:
15219 bad_subwidg_type("MaxDigits", false, ty);
15220 ret = -10000;
15221 break;
15222 }
15223 }
15224 break;
15225 }
15226 case SUBWIDGTY_INFITM:
15227 {
15228 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "InfiniteItem"))
15229 {
15230 auto ty = widg->getType();
15231 switch(ty)
15232 {
15233 case widgCOUNTER:
15234 ret = 10000*((SW_Counter*)widg)->infitm;
15235 break;
15236 case widgOLDCTR:
15237 ret = 10000*((SW_Counters*)widg)->infitm;
15238 break;
15239 case widgLGAUGE:
15240 case widgMGAUGE:
15241 case widgMISCGAUGE:
15242 ret = 10000*((SW_GaugePiece*)widg)->inf_item;
15243 break;
15244 default:
15245 bad_subwidg_type("InfiniteItem", false, ty);
15246 ret = -10000;
15247 break;
15248 }
15249 }
15250 break;
15251 }
15252 case SUBWIDGTY_INFCHAR:
15253 {
15254 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "InfiniteChar"))
15255 {
15256 auto ty = widg->getType();
15257 switch(ty)
15258 {
15259 case widgCOUNTER:
15260 ret = 10000*byte(((SW_Counter*)widg)->infchar);
15261 break;
15262 case widgOLDCTR:
15263 ret = 10000*byte(((SW_Counters*)widg)->infchar);
15264 break;
15265 case widgBTNCOUNTER:
15266 ret = 10000*byte(((SW_BtnCounter*)widg)->infchar);
15267 break;
15268 default:
15269 bad_subwidg_type("InfiniteChar", false, ty);
15270 break;
15271 }
15272 }
15273 break;
15274 }
15275 case SUBWIDGTY_COSTIND:
15276 {
15277 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "CostIndex"))
15278 {
15279 auto ty = widg->getType();
15280 switch(ty)
15281 {
15282 case widgBTNCOUNTER:
15283 ret = 10000*((SW_BtnCounter*)widg)->costind;
15284 break;
15285 default:
15286 bad_subwidg_type("CostIndex", false, ty);
15287 ret = -1;
15288 break;
15289 }
15290 }
15291 break;
15292 }
15293 case SUBWIDGTY_COLOR_PLAYER:
15294 {
15295 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorPlayer"))
15296 {
15297 auto ty = widg->getType();
15298 switch(ty)
15299 {
15300 case widgMMAP:
15301 ret = 10000*((SW_MMap*)widg)->c_plr.get_int_color();
15302 break;
15303 case widgLMAP:
15304 ret = 10000*((SW_LMap*)widg)->c_plr.get_int_color();
15305 break;
15306 default:
15307 bad_subwidg_type("ColorPlayer", false, ty);
15308 break;
15309 }
15310 }
15311 break;
15312 }
15313 case SUBWIDGTY_COLOR_CMPBLNK:
15314 {
15315 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorCompassBlink"))
15316 {
15317 auto ty = widg->getType();
15318 switch(ty)
15319 {
15320 case widgMMAP:
15321 ret = 10000*((SW_MMap*)widg)->c_cmp_blink.get_int_color();
15322 break;
15323 default:
15324 bad_subwidg_type("ColorCompassBlink", false, ty);
15325 break;
15326 }
15327 }
15328 break;
15329 }
15330 case SUBWIDGTY_COLOR_CMPOFF:
15331 {
15332 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorCompassOff"))
15333 {
15334 auto ty = widg->getType();
15335 switch(ty)
15336 {
15337 case widgMMAP:
15338 ret = 10000*((SW_MMap*)widg)->c_cmp_off.get_int_color();
15339 break;
15340 default:
15341 bad_subwidg_type("ColorCompassOff", false, ty);
15342 break;
15343 }
15344 }
15345 break;
15346 }
15347 case SUBWIDGTY_COLOR_ROOM:
15348 {
15349 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorRoom"))
15350 {
15351 auto ty = widg->getType();
15352 switch(ty)
15353 {
15354 case widgLMAP:
15355 ret = 10000*((SW_LMap*)widg)->c_room.get_int_color();
15356 break;
15357 default:
15358 bad_subwidg_type("ColorRoom", false, ty);
15359 break;
15360 }
15361 }
15362 break;
15363 }
15364 case SUBWIDGTY_ITEMCLASS:
15365 {
15366 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ItemClass"))
15367 {
15368 auto ty = widg->getType();
15369 switch(ty)
15370 {
15371 case widgITEMSLOT:
15372 ret = 10000*((SW_ItemSlot*)widg)->iclass;
15373 break;
15374 default:
15375 bad_subwidg_type("ItemClass", false, ty);
15376 break;
15377 }
15378 }
15379 break;
15380 }
15381 case SUBWIDGTY_ITEMID:
15382 {
15383 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ItemID"))
15384 {
15385 auto ty = widg->getType();
15386 switch(ty)
15387 {
15388 case widgITEMSLOT:
15389 ret = 10000*((SW_ItemSlot*)widg)->iid;
15390 break;
15391 default:
15392 bad_subwidg_type("ItemID", false, ty);
15393 break;
15394 }
15395 }
15396 break;
15397 }
15398 case SUBWIDGTY_FRAMETILE:
15399 {
15400 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "FrameTile"))
15401 {
15402 auto ty = widg->getType();
15403 switch(ty)
15404 {
15405 case widgMCGUFF_FRAME:
15406 ret = 10000*((SW_TriFrame*)widg)->frame_tile;
15407 break;
15408 default:
15409 bad_subwidg_type("FrameTile", false, ty);
15410 break;
15411 }
15412 }
15413 break;
15414 }
15415 case SUBWIDGTY_FRAMECSET:
15416 {
15417 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "FrameCSet"))
15418 {
15419 auto ty = widg->getType();
15420 switch(ty)
15421 {
15422 case widgMCGUFF_FRAME:
15423 ret = 10000*((SW_TriFrame*)widg)->frame_cset;
15424 break;
15425 default:
15426 bad_subwidg_type("FrameCSet", false, ty);
15427 break;
15428 }
15429 }
15430 break;
15431 }
15432 case SUBWIDGTY_PIECETILE:
15433 {
15434 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PieceTile"))
15435 {
15436 auto ty = widg->getType();
15437 switch(ty)
15438 {
15439 case widgMCGUFF_FRAME:
15440 ret = 10000*((SW_TriFrame*)widg)->piece_tile;
15441 break;
15442 default:
15443 bad_subwidg_type("PieceTile", false, ty);
15444 break;
15445 }
15446 }
15447 break;
15448 }
15449 case SUBWIDGTY_PIECECSET:
15450 {
15451 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PieceCSet"))
15452 {
15453 auto ty = widg->getType();
15454 switch(ty)
15455 {
15456 case widgMCGUFF_FRAME:
15457 ret = 10000*((SW_TriFrame*)widg)->piece_cset;
15458 break;
15459 default:
15460 bad_subwidg_type("PieceCSet", false, ty);
15461 break;
15462 }
15463 }
15464 break;
15465 }
15466 case SUBWIDGTY_FLIP:
15467 {
15468 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Flip"))
15469 {
15470 auto ty = widg->getType();
15471 switch(ty)
15472 {
15473 case widgMCGUFF:
15474 ret = 10000*((SW_McGuffin*)widg)->flip;
15475 break;
15476 case widgTILEBLOCK:
15477 ret = 10000*((SW_TileBlock*)widg)->flip;
15478 break;
15479 case widgMINITILE:
15480 ret = 10000*((SW_MiniTile*)widg)->flip;
15481 break;
15482 default:
15483 bad_subwidg_type("Flip", false, ty);
15484 break;
15485 }
15486 }
15487 break;
15488 }
15489 case SUBWIDGTY_NUMBER:
15490 {
15491 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Number"))
15492 {
15493 auto ty = widg->getType();
15494 switch(ty)
15495 {
15496 case widgMCGUFF:
15497 ret = 10000*((SW_McGuffin*)widg)->number;
15498 break;
15499 default:
15500 bad_subwidg_type("Number", false, ty);
15501 break;
15502 }
15503 }
15504 break;
15505 }
15506 case SUBWIDGTY_CORNER:
15507 {
15508 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Corner"))
15509 {
15510 size_t indx = ri->d[rINDEX]/10000;
15511 size_t sz = 0;
15512 byte ty = widg->getType();
15513 switch(ty)
15514 {
15515 case widgMINITILE:
15516 sz = 1;
15517 break;
15518 case widgLGAUGE:
15519 case widgMGAUGE:
15520 case widgMISCGAUGE:
15521 sz = 4;
15522 break;
15523 default:
15524 sz = 0;
15525 bad_subwidg_type("Corner[]", false, ty);
15526 ret = -10000;
15527 break;
15528 }
15529 if(!sz) break;
15530 if(indx >= sz)
15531 {
15532 Z_scripterrlog("Bad index '%d' to array "
15533 "'subscreenwidget->Corner[%d]'\n", indx, sz);
15534 break;
15535 }
15536 switch(ty)
15537 {
15538 case widgMINITILE:
15539 ret = 10000*((SW_MiniTile*)widg)->crn;
15540 break;
15541 case widgLGAUGE:
15542 case widgMGAUGE:
15543 case widgMISCGAUGE:
15544 ret = 10000*((SW_GaugePiece*)widg)->mts[indx].crn();
15545 break;
15546 }
15547 }
15548 break;
15549 }
15550 case SUBWIDGTY_FRAMES:
15551 {
15552 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Frames"))
15553 {
15554 auto ty = widg->getType();
15555 switch(ty)
15556 {
15557 case widgLGAUGE:
15558 case widgMGAUGE:
15559 case widgMISCGAUGE:
15560 ret = 10000*((SW_GaugePiece*)widg)->frames;
15561 break;
15562 default:
15563 bad_subwidg_type("Frames", false, ty);
15564 ret = -10000;
15565 break;
15566 }
15567 }
15568 break;
15569 }
15570 case SUBWIDGTY_SPEED:
15571 {
15572 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Speed"))
15573 {
15574 auto ty = widg->getType();
15575 switch(ty)
15576 {
15577 case widgLGAUGE:
15578 case widgMGAUGE:
15579 case widgMISCGAUGE:
15580 ret = 10000*((SW_GaugePiece*)widg)->speed;
15581 break;
15582 default:
15583 bad_subwidg_type("Speed", false, ty);
15584 ret = -10000;
15585 break;
15586 }
15587 }
15588 break;
15589 }
15590 case SUBWIDGTY_DELAY:
15591 {
15592 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Delay"))
15593 {
15594 auto ty = widg->getType();
15595 switch(ty)
15596 {
15597 case widgLGAUGE:
15598 case widgMGAUGE:
15599 case widgMISCGAUGE:
15600 ret = 10000*((SW_GaugePiece*)widg)->delay;
15601 break;
15602 default:
15603 bad_subwidg_type("Delay", false, ty);
15604 ret = -10000;
15605 break;
15606 }
15607 }
15608 break;
15609 }
15610 case SUBWIDGTY_CONTAINER:
15611 {
15612 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Container"))
15613 {
15614 auto ty = widg->getType();
15615 switch(ty)
15616 {
15617 case widgLGAUGE:
15618 case widgMGAUGE:
15619 case widgMISCGAUGE:
15620 ret = 10000*((SW_GaugePiece*)widg)->container;
15621 break;
15622 default:
15623 bad_subwidg_type("Container", false, ty);
15624 ret = -10000;
15625 break;
15626 }
15627 }
15628 break;
15629 }
15630 case SUBWIDGTY_GAUGE_WID:
15631 {
15632 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GaugeWid"))
15633 {
15634 auto ty = widg->getType();
15635 switch(ty)
15636 {
15637 case widgLGAUGE:
15638 case widgMGAUGE:
15639 case widgMISCGAUGE:
15640 ret = 10000*(((SW_GaugePiece*)widg)->gauge_wid+1);
15641 break;
15642 default:
15643 bad_subwidg_type("GaugeWid", false, ty);
15644 ret = -10000;
15645 break;
15646 }
15647 }
15648 break;
15649 }
15650 case SUBWIDGTY_GAUGE_HEI:
15651 {
15652 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GaugeHei"))
15653 {
15654 auto ty = widg->getType();
15655 switch(ty)
15656 {
15657 case widgLGAUGE:
15658 case widgMGAUGE:
15659 case widgMISCGAUGE:
15660 ret = 10000*(((SW_GaugePiece*)widg)->gauge_hei+1);
15661 break;
15662 default:
15663 bad_subwidg_type("GaugeHei", false, ty);
15664 ret = -10000;
15665 break;
15666 }
15667 }
15668 break;
15669 }
15670 case SUBWIDGTY_UNITS:
15671 {
15672 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Units"))
15673 {
15674 auto ty = widg->getType();
15675 switch(ty)
15676 {
15677 case widgLGAUGE:
15678 case widgMGAUGE:
15679 case widgMISCGAUGE:
15680 ret = 10000*(((SW_GaugePiece*)widg)->unit_per_frame+1);
15681 break;
15682 default:
15683 bad_subwidg_type("Units", false, ty);
15684 ret = -10000;
15685 break;
15686 }
15687 }
15688 break;
15689 }
15690 case SUBWIDGTY_HSPACE:
15691 {
15692 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "HSpace"))
15693 {
15694 auto ty = widg->getType();
15695 switch(ty)
15696 {
15697 case widgLGAUGE:
15698 case widgMGAUGE:
15699 case widgMISCGAUGE:
15700 ret = 10000*((SW_GaugePiece*)widg)->hspace;
15701 break;
15702 default:
15703 bad_subwidg_type("HSpace", false, ty);
15704 ret = -10000;
15705 break;
15706 }
15707 }
15708 break;
15709 }
15710 case SUBWIDGTY_VSPACE:
15711 {
15712 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "VSpace"))
15713 {
15714 auto ty = widg->getType();
15715 switch(ty)
15716 {
15717 case widgLGAUGE:
15718 case widgMGAUGE:
15719 case widgMISCGAUGE:
15720 ret = 10000*((SW_GaugePiece*)widg)->vspace;
15721 break;
15722 default:
15723 bad_subwidg_type("VSpace", false, ty);
15724 ret = -10000;
15725 break;
15726 }
15727 }
15728 break;
15729 }
15730 case SUBWIDGTY_GRIDX:
15731 {
15732 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GridX"))
15733 {
15734 auto ty = widg->getType();
15735 switch(ty)
15736 {
15737 case widgLGAUGE:
15738 case widgMGAUGE:
15739 case widgMISCGAUGE:
15740 ret = 10000*((SW_GaugePiece*)widg)->grid_xoff;
15741 break;
15742 default:
15743 bad_subwidg_type("GridX", false, ty);
15744 ret = -10000;
15745 break;
15746 }
15747 }
15748 break;
15749 }
15750 case SUBWIDGTY_GRIDY:
15751 {
15752 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GridY"))
15753 {
15754 auto ty = widg->getType();
15755 switch(ty)
15756 {
15757 case widgLGAUGE:
15758 case widgMGAUGE:
15759 case widgMISCGAUGE:
15760 ret = 10000*((SW_GaugePiece*)widg)->grid_yoff;
15761 break;
15762 default:
15763 bad_subwidg_type("GridY", false, ty);
15764 ret = -10000;
15765 break;
15766 }
15767 }
15768 break;
15769 }
15770 case SUBWIDGTY_ANIMVAL:
15771 {
15772 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "AnimVal"))
15773 {
15774 auto ty = widg->getType();
15775 switch(ty)
15776 {
15777 case widgLGAUGE:
15778 case widgMGAUGE:
15779 case widgMISCGAUGE:
15780 ret = 10000*((SW_GaugePiece*)widg)->anim_val;
15781 break;
15782 default:
15783 bad_subwidg_type("AnimVal", false, ty);
15784 ret = -10000;
15785 break;
15786 }
15787 }
15788 break;
15789 }
15790 case SUBWIDGTY_SHOWDRAIN:
15791 {
15792 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ShowDrain"))
15793 {
15794 auto ty = widg->getType();
15795 switch(ty)
15796 {
15797 case widgMGAUGE:
15798 ret = 10000*((SW_MagicGaugePiece*)widg)->showdrain;
15799 break;
15800 default:
15801 bad_subwidg_type("ShowDrain", false, ty);
15802 ret = -10000;
15803 break;
15804 }
15805 }
15806 break;
15807 }
15808 case SUBWIDGTY_PERCONTAINER:
15809 {
15810 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PerContainer"))
15811 {
15812 auto ty = widg->getType();
15813 switch(ty)
15814 {
15815 case widgMGAUGE:
15816 ret = 10000*((SW_MiscGaugePiece*)widg)->per_container;
15817 break;
15818 default:
15819 bad_subwidg_type("PerContainer", false, ty);
15820 ret = -10000;
15821 break;
15822 }
15823 }
15824 break;
15825 }
15826 case SUBWIDGTY_TABSIZE:
15827 {
15828 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "TabSize"))
15829 {
15830 auto ty = widg->getType();
15831 switch(ty)
15832 {
15833 case widgTEXTBOX:
15834 ret = 10000*((SW_TextBox*)widg)->tabsize;
15835 break;
15836 case widgSELECTEDTEXT:
15837 ret = 10000*((SW_SelectedText*)widg)->tabsize;
15838 break;
15839 default:
15840 bad_subwidg_type("TabSize", false, ty);
15841 ret = -10000;
15842 break;
15843 }
15844 }
15845 break;
15846 }
15847 ///----------------------------------------------------------------------------------------------------//
15848
15849 default:
15850 {
15851
2/4
✓ Branch 0 taken 751885248 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 751885248 times.
751885248 if(arg >= D(0) && arg <= D(7)) ret = ri->d[arg - D(0)];
15852 else if(arg >= A(0) && arg <= A(1)) ret = ri->a[arg - A(0)];
15853 else if(arg >= GD(0) && arg <= GD(MAX_SCRIPT_REGISTERS)) ret = game->global_d[arg - GD(0)];
15854
15855 751885248 break;
15856 }
15857 }
15858
15859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2767297062 times.
2767297062 if ( zasm_debugger ) FFCore.ZASMPrintVarGet(arg, ret);
15860 2767297062 return ret;
15861 }
15862
15863 //Setter Instructions
15864
15865
15866 1401361252 void set_register(int32_t arg, int32_t value)
15867 {
15868
1/2
✓ Branch 0 taken 1401361252 times.
✗ Branch 1 not taken.
1401361252 if ( zasm_debugger ) FFCore.ZASMPrintVarSet(arg, value);
15869 //Macros
15870
15871 #define SET_SPRITEDATA_VAR_INT(member, str) \
15872 { \
15873 if(unsigned(ri->spritesref) > (MAXWPNS-1) ) \
15874 { \
15875 Z_scripterrlog("Invalid Sprite ID passed to spritedata->%s: %d\n", str, (ri->spritesref*10000)); \
15876 } \
15877 else \
15878 { \
15879 wpnsbuf[ri->spritesref].member = vbound((value / 10000),0,214747); \
15880 } \
15881 } \
15882
15883 #define SET_SPRITEDATA_VAR_BYTE(member, str) \
15884 { \
15885 if(unsigned(ri->spritesref) > (MAXWPNS-1) ) \
15886 { \
15887 Z_scripterrlog("Invalid Sprite ID passed to spritedata->%s: %d\n", str, (ri->spritesref*10000)); \
15888 } \
15889 else \
15890 { \
15891 wpnsbuf[ri->spritesref].member = vbound((value / 10000),0,255); \
15892 } \
15893 } \
15894
15895
246/1329
✓ Branch 0 taken 2272629 times.
✓ Branch 1 taken 2881 times.
✓ Branch 2 taken 3250 times.
✓ Branch 3 taken 616 times.
✓ Branch 4 taken 900 times.
✓ Branch 5 taken 64379 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1532 times.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 5161 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 2569 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 928305 times.
✓ Branch 31 taken 249228 times.
✓ Branch 32 taken 236880 times.
✓ Branch 33 taken 89166 times.
✓ Branch 34 taken 78737 times.
✓ Branch 35 taken 78784 times.
✓ Branch 36 taken 222649 times.
✓ Branch 37 taken 222649 times.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✓ Branch 41 taken 461908 times.
✓ Branch 42 taken 218364 times.
✓ Branch 43 taken 218431 times.
✓ Branch 44 taken 83086 times.
✓ Branch 45 taken 222649 times.
✓ Branch 46 taken 222649 times.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✓ Branch 50 taken 21848 times.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✓ Branch 53 taken 37 times.
✗ Branch 54 not taken.
✓ Branch 55 taken 109 times.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✓ Branch 58 taken 40 times.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✓ Branch 65 taken 6 times.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✓ Branch 68 taken 787 times.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✓ Branch 71 taken 68 times.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✓ Branch 80 taken 193756 times.
✓ Branch 81 taken 1 times.
✓ Branch 82 taken 193749 times.
✗ Branch 83 not taken.
✗ Branch 84 not taken.
✗ Branch 85 not taken.
✓ Branch 86 taken 139174 times.
✗ Branch 87 not taken.
✗ Branch 88 not taken.
✓ Branch 89 taken 16 times.
✓ Branch 90 taken 1841 times.
✓ Branch 91 taken 60616 times.
✗ Branch 92 not taken.
✓ Branch 93 taken 61740 times.
✓ Branch 94 taken 10 times.
✓ Branch 95 taken 16120 times.
✗ Branch 96 not taken.
✓ Branch 97 taken 60902 times.
✓ Branch 98 taken 603 times.
✗ Branch 99 not taken.
✗ Branch 100 not taken.
✗ Branch 101 not taken.
✗ Branch 102 not taken.
✗ Branch 103 not taken.
✓ Branch 104 taken 226569 times.
✓ Branch 105 taken 1 times.
✓ Branch 106 taken 226856 times.
✗ Branch 107 not taken.
✓ Branch 108 taken 131702 times.
✓ Branch 109 taken 12175 times.
✓ Branch 110 taken 23997 times.
✗ Branch 111 not taken.
✗ Branch 112 not taken.
✓ Branch 113 taken 41 times.
✗ Branch 114 not taken.
✓ Branch 115 taken 41 times.
✓ Branch 116 taken 549 times.
✓ Branch 117 taken 137776 times.
✓ Branch 118 taken 35370 times.
✓ Branch 119 taken 910117 times.
✗ Branch 120 not taken.
✗ Branch 121 not taken.
✗ Branch 122 not taken.
✗ Branch 123 not taken.
✗ Branch 124 not taken.
✗ Branch 125 not taken.
✗ Branch 126 not taken.
✗ Branch 127 not taken.
✗ Branch 128 not taken.
✗ Branch 129 not taken.
✗ Branch 130 not taken.
✗ Branch 131 not taken.
✗ Branch 132 not taken.
✓ Branch 133 taken 3 times.
✗ Branch 134 not taken.
✓ Branch 135 taken 970520 times.
✗ Branch 136 not taken.
✗ Branch 137 not taken.
✗ Branch 138 not taken.
✗ Branch 139 not taken.
✓ Branch 140 taken 1034127 times.
✗ Branch 141 not taken.
✗ Branch 142 not taken.
✓ Branch 143 taken 13 times.
✓ Branch 144 taken 77612 times.
✓ Branch 145 taken 7068 times.
✓ Branch 146 taken 28759 times.
✗ Branch 147 not taken.
✗ Branch 148 not taken.
✓ Branch 149 taken 545362 times.
✗ Branch 150 not taken.
✗ Branch 151 not taken.
✗ Branch 152 not taken.
✗ Branch 153 not taken.
✗ Branch 154 not taken.
✗ Branch 155 not taken.
✗ Branch 156 not taken.
✗ Branch 157 not taken.
✗ Branch 158 not taken.
✗ Branch 159 not taken.
✗ Branch 160 not taken.
✗ Branch 161 not taken.
✓ Branch 162 taken 551 times.
✗ Branch 163 not taken.
✗ Branch 164 not taken.
✗ Branch 165 not taken.
✗ Branch 166 not taken.
✗ Branch 167 not taken.
✗ Branch 168 not taken.
✓ Branch 169 taken 889 times.
✗ Branch 170 not taken.
✗ Branch 171 not taken.
✗ Branch 172 not taken.
✗ Branch 173 not taken.
✗ Branch 174 not taken.
✗ Branch 175 not taken.
✗ Branch 176 not taken.
✗ Branch 177 not taken.
✗ Branch 178 not taken.
✗ Branch 179 not taken.
✗ Branch 180 not taken.
✗ Branch 181 not taken.
✗ Branch 182 not taken.
✗ Branch 183 not taken.
✗ Branch 184 not taken.
✗ Branch 185 not taken.
✗ Branch 186 not taken.
✗ Branch 187 not taken.
✗ Branch 188 not taken.
✗ Branch 189 not taken.
✗ Branch 190 not taken.
✓ Branch 191 taken 900 times.
✓ Branch 192 taken 7214 times.
✗ Branch 193 not taken.
✗ Branch 194 not taken.
✗ Branch 195 not taken.
✗ Branch 196 not taken.
✗ Branch 197 not taken.
✗ Branch 198 not taken.
✗ Branch 199 not taken.
✗ Branch 200 not taken.
✗ Branch 201 not taken.
✗ Branch 202 not taken.
✗ Branch 203 not taken.
✗ Branch 204 not taken.
✗ Branch 205 not taken.
✗ Branch 206 not taken.
✗ Branch 207 not taken.
✗ Branch 208 not taken.
✓ Branch 209 taken 503812264 times.
✓ Branch 210 taken 2162208 times.
✓ Branch 211 taken 10116373 times.
✓ Branch 212 taken 23554631 times.
✓ Branch 213 taken 78146347 times.
✓ Branch 214 taken 116558 times.
✗ Branch 215 not taken.
✗ Branch 216 not taken.
✗ Branch 217 not taken.
✗ Branch 218 not taken.
✗ Branch 219 not taken.
✗ Branch 220 not taken.
✗ Branch 221 not taken.
✓ Branch 222 taken 303330 times.
✗ Branch 223 not taken.
✗ Branch 224 not taken.
✗ Branch 225 not taken.
✗ Branch 226 not taken.
✗ Branch 227 not taken.
✗ Branch 228 not taken.
✗ Branch 229 not taken.
✗ Branch 230 not taken.
✗ Branch 231 not taken.
✗ Branch 232 not taken.
✗ Branch 233 not taken.
✗ Branch 234 not taken.
✗ Branch 235 not taken.
✗ Branch 236 not taken.
✗ Branch 237 not taken.
✗ Branch 238 not taken.
✗ Branch 239 not taken.
✗ Branch 240 not taken.
✗ Branch 241 not taken.
✗ Branch 242 not taken.
✗ Branch 243 not taken.
✗ Branch 244 not taken.
✗ Branch 245 not taken.
✗ Branch 246 not taken.
✗ Branch 247 not taken.
✗ Branch 248 not taken.
✗ Branch 249 not taken.
✗ Branch 250 not taken.
✗ Branch 251 not taken.
✗ Branch 252 not taken.
✗ Branch 253 not taken.
✗ Branch 254 not taken.
✗ Branch 255 not taken.
✗ Branch 256 not taken.
✗ Branch 257 not taken.
✓ Branch 258 taken 455505918 times.
✗ Branch 259 not taken.
✗ Branch 260 not taken.
✓ Branch 261 taken 261989134 times.
✗ Branch 262 not taken.
✓ Branch 263 taken 9725 times.
✓ Branch 264 taken 1042466 times.
✓ Branch 265 taken 1215066 times.
✓ Branch 266 taken 1217071 times.
✓ Branch 267 taken 9445 times.
✓ Branch 268 taken 9429 times.
✗ Branch 269 not taken.
✓ Branch 270 taken 9173 times.
✓ Branch 271 taken 9173 times.
✓ Branch 272 taken 229040 times.
✓ Branch 273 taken 3248 times.
✓ Branch 274 taken 9503 times.
✓ Branch 275 taken 9513 times.
✓ Branch 276 taken 17707 times.
✗ Branch 277 not taken.
✗ Branch 278 not taken.
✓ Branch 279 taken 444601 times.
✗ Branch 280 not taken.
✓ Branch 281 taken 458940 times.
✓ Branch 282 taken 2769 times.
✓ Branch 283 taken 93694 times.
✗ Branch 284 not taken.
✗ Branch 285 not taken.
✓ Branch 286 taken 270554 times.
✓ Branch 287 taken 10416 times.
✓ Branch 288 taken 56 times.
✗ Branch 289 not taken.
✓ Branch 290 taken 388 times.
✗ Branch 291 not taken.
✗ Branch 292 not taken.
✗ Branch 293 not taken.
✗ Branch 294 not taken.
✓ Branch 295 taken 5906 times.
✗ Branch 296 not taken.
✗ Branch 297 not taken.
✓ Branch 298 taken 740 times.
✗ Branch 299 not taken.
✓ Branch 300 taken 56626 times.
✗ Branch 301 not taken.
✗ Branch 302 not taken.
✗ Branch 303 not taken.
✗ Branch 304 not taken.
✗ Branch 305 not taken.
✗ Branch 306 not taken.
✓ Branch 307 taken 280560 times.
✗ Branch 308 not taken.
✗ Branch 309 not taken.
✗ Branch 310 not taken.
✗ Branch 311 not taken.
✗ Branch 312 not taken.
✗ Branch 313 not taken.
✗ Branch 314 not taken.
✗ Branch 315 not taken.
✗ Branch 316 not taken.
✗ Branch 317 not taken.
✗ Branch 318 not taken.
✗ Branch 319 not taken.
✗ Branch 320 not taken.
✓ Branch 321 taken 93759 times.
✓ Branch 322 taken 93760 times.
✓ Branch 323 taken 93772 times.
✓ Branch 324 taken 93778 times.
✗ Branch 325 not taken.
✗ Branch 326 not taken.
✗ Branch 327 not taken.
✗ Branch 328 not taken.
✓ Branch 329 taken 2569 times.
✗ Branch 330 not taken.
✗ Branch 331 not taken.
✗ Branch 332 not taken.
✗ Branch 333 not taken.
✗ Branch 334 not taken.
✗ Branch 335 not taken.
✗ Branch 336 not taken.
✗ Branch 337 not taken.
✗ Branch 338 not taken.
✗ Branch 339 not taken.
✓ Branch 340 taken 166 times.
✗ Branch 341 not taken.
✗ Branch 342 not taken.
✗ Branch 343 not taken.
✗ Branch 344 not taken.
✗ Branch 345 not taken.
✓ Branch 346 taken 461908 times.
✓ Branch 347 taken 249220 times.
✓ Branch 348 taken 236658 times.
✓ Branch 349 taken 76223 times.
✓ Branch 350 taken 222649 times.
✓ Branch 351 taken 222649 times.
✗ Branch 352 not taken.
✓ Branch 353 taken 928305 times.
✓ Branch 354 taken 218369 times.
✓ Branch 355 taken 218461 times.
✓ Branch 356 taken 70141 times.
✓ Branch 357 taken 75869 times.
✓ Branch 358 taken 75916 times.
✓ Branch 359 taken 222649 times.
✓ Branch 360 taken 222649 times.
✗ Branch 361 not taken.
✗ Branch 362 not taken.
✗ Branch 363 not taken.
✗ Branch 364 not taken.
✗ Branch 365 not taken.
✗ Branch 366 not taken.
✓ Branch 367 taken 281179 times.
✓ Branch 368 taken 281265 times.
✗ Branch 369 not taken.
✗ Branch 370 not taken.
✗ Branch 371 not taken.
✗ Branch 372 not taken.
✗ Branch 373 not taken.
✗ Branch 374 not taken.
✗ Branch 375 not taken.
✗ Branch 376 not taken.
✗ Branch 377 not taken.
✗ Branch 378 not taken.
✗ Branch 379 not taken.
✗ Branch 380 not taken.
✓ Branch 381 taken 31 times.
✗ Branch 382 not taken.
✓ Branch 383 taken 41791 times.
✓ Branch 384 taken 92 times.
✓ Branch 385 taken 49959 times.
✗ Branch 386 not taken.
✗ Branch 387 not taken.
✗ Branch 388 not taken.
✗ Branch 389 not taken.
✗ Branch 390 not taken.
✗ Branch 391 not taken.
✗ Branch 392 not taken.
✗ Branch 393 not taken.
✗ Branch 394 not taken.
✗ Branch 395 not taken.
✗ Branch 396 not taken.
✗ Branch 397 not taken.
✗ Branch 398 not taken.
✗ Branch 399 not taken.
✗ Branch 400 not taken.
✗ Branch 401 not taken.
✗ Branch 402 not taken.
✗ Branch 403 not taken.
✓ Branch 404 taken 3013 times.
✗ Branch 405 not taken.
✗ Branch 406 not taken.
✗ Branch 407 not taken.
✗ Branch 408 not taken.
✗ Branch 409 not taken.
✗ Branch 410 not taken.
✗ Branch 411 not taken.
✗ Branch 412 not taken.
✗ Branch 413 not taken.
✗ Branch 414 not taken.
✗ Branch 415 not taken.
✗ Branch 416 not taken.
✗ Branch 417 not taken.
✗ Branch 418 not taken.
✗ Branch 419 not taken.
✗ Branch 420 not taken.
✗ Branch 421 not taken.
✗ Branch 422 not taken.
✗ Branch 423 not taken.
✗ Branch 424 not taken.
✗ Branch 425 not taken.
✗ Branch 426 not taken.
✗ Branch 427 not taken.
✗ Branch 428 not taken.
✗ Branch 429 not taken.
✗ Branch 430 not taken.
✗ Branch 431 not taken.
✗ Branch 432 not taken.
✗ Branch 433 not taken.
✗ Branch 434 not taken.
✗ Branch 435 not taken.
✗ Branch 436 not taken.
✗ Branch 437 not taken.
✗ Branch 438 not taken.
✗ Branch 439 not taken.
✗ Branch 440 not taken.
✗ Branch 441 not taken.
✗ Branch 442 not taken.
✗ Branch 443 not taken.
✗ Branch 444 not taken.
✗ Branch 445 not taken.
✗ Branch 446 not taken.
✗ Branch 447 not taken.
✗ Branch 448 not taken.
✗ Branch 449 not taken.
✗ Branch 450 not taken.
✗ Branch 451 not taken.
✗ Branch 452 not taken.
✗ Branch 453 not taken.
✗ Branch 454 not taken.
✗ Branch 455 not taken.
✗ Branch 456 not taken.
✗ Branch 457 not taken.
✗ Branch 458 not taken.
✗ Branch 459 not taken.
✗ Branch 460 not taken.
✗ Branch 461 not taken.
✗ Branch 462 not taken.
✗ Branch 463 not taken.
✗ Branch 464 not taken.
✗ Branch 465 not taken.
✗ Branch 466 not taken.
✗ Branch 467 not taken.
✗ Branch 468 not taken.
✗ Branch 469 not taken.
✗ Branch 470 not taken.
✗ Branch 471 not taken.
✗ Branch 472 not taken.
✗ Branch 473 not taken.
✓ Branch 474 taken 2760 times.
✗ Branch 475 not taken.
✗ Branch 476 not taken.
✗ Branch 477 not taken.
✗ Branch 478 not taken.
✗ Branch 479 not taken.
✗ Branch 480 not taken.
✗ Branch 481 not taken.
✓ Branch 482 taken 70 times.
✗ Branch 483 not taken.
✗ Branch 484 not taken.
✗ Branch 485 not taken.
✗ Branch 486 not taken.
✗ Branch 487 not taken.
✗ Branch 488 not taken.
✗ Branch 489 not taken.
✓ Branch 490 taken 180 times.
✗ Branch 491 not taken.
✓ Branch 492 taken 65054 times.
✗ Branch 493 not taken.
✓ Branch 494 taken 8276 times.
✓ Branch 495 taken 1469 times.
✗ Branch 496 not taken.
✗ Branch 497 not taken.
✗ Branch 498 not taken.
✓ Branch 499 taken 1175 times.
✓ Branch 500 taken 16 times.
✓ Branch 501 taken 49 times.
✓ Branch 502 taken 69347 times.
✓ Branch 503 taken 1853 times.
✓ Branch 504 taken 3221 times.
✗ Branch 505 not taken.
✓ Branch 506 taken 2065 times.
✗ Branch 507 not taken.
✓ Branch 508 taken 404 times.
✗ Branch 509 not taken.
✓ Branch 510 taken 457 times.
✓ Branch 511 taken 683 times.
✓ Branch 512 taken 4922 times.
✗ Branch 513 not taken.
✓ Branch 514 taken 60616 times.
✓ Branch 515 taken 156 times.
✓ Branch 516 taken 63470 times.
✗ Branch 517 not taken.
✗ Branch 518 not taken.
✗ Branch 519 not taken.
✓ Branch 520 taken 61757 times.
✗ Branch 521 not taken.
✓ Branch 522 taken 10 times.
✓ Branch 523 taken 497624 times.
✗ Branch 524 not taken.
✗ Branch 525 not taken.
✓ Branch 526 taken 238 times.
✗ Branch 527 not taken.
✗ Branch 528 not taken.
✗ Branch 529 not taken.
✗ Branch 530 not taken.
✓ Branch 531 taken 265 times.
✗ Branch 532 not taken.
✗ Branch 533 not taken.
✗ Branch 534 not taken.
✗ Branch 535 not taken.
✗ Branch 536 not taken.
✗ Branch 537 not taken.
✗ Branch 538 not taken.
✗ Branch 539 not taken.
✗ Branch 540 not taken.
✗ Branch 541 not taken.
✗ Branch 542 not taken.
✗ Branch 543 not taken.
✗ Branch 544 not taken.
✓ Branch 545 taken 6823 times.
✓ Branch 546 taken 6048 times.
✓ Branch 547 taken 138270 times.
✗ Branch 548 not taken.
✗ Branch 549 not taken.
✓ Branch 550 taken 264908 times.
✓ Branch 551 taken 134925 times.
✗ Branch 552 not taken.
✗ Branch 553 not taken.
✗ Branch 554 not taken.
✗ Branch 555 not taken.
✓ Branch 556 taken 47 times.
✓ Branch 557 taken 132679 times.
✗ Branch 558 not taken.
✓ Branch 559 taken 9747 times.
✗ Branch 560 not taken.
✓ Branch 561 taken 2072 times.
✓ Branch 562 taken 49622 times.
✓ Branch 563 taken 1104 times.
✓ Branch 564 taken 111461 times.
✓ Branch 565 taken 4552 times.
✗ Branch 566 not taken.
✓ Branch 567 taken 138269 times.
✓ Branch 568 taken 38448 times.
✗ Branch 569 not taken.
✗ Branch 570 not taken.
✗ Branch 571 not taken.
✗ Branch 572 not taken.
✓ Branch 573 taken 234661 times.
✓ Branch 574 taken 234074 times.
✓ Branch 575 taken 44 times.
✓ Branch 576 taken 111461 times.
✓ Branch 577 taken 111461 times.
✓ Branch 578 taken 20016 times.
✗ Branch 579 not taken.
✗ Branch 580 not taken.
✓ Branch 581 taken 1275 times.
✓ Branch 582 taken 4214 times.
✗ Branch 583 not taken.
✗ Branch 584 not taken.
✗ Branch 585 not taken.
✗ Branch 586 not taken.
✗ Branch 587 not taken.
✗ Branch 588 not taken.
✗ Branch 589 not taken.
✗ Branch 590 not taken.
✗ Branch 591 not taken.
✓ Branch 592 taken 1038288 times.
✗ Branch 593 not taken.
✗ Branch 594 not taken.
✗ Branch 595 not taken.
✗ Branch 596 not taken.
✓ Branch 597 taken 1042699 times.
✓ Branch 598 taken 973735 times.
✗ Branch 599 not taken.
✓ Branch 600 taken 71 times.
✗ Branch 601 not taken.
✓ Branch 602 taken 21269 times.
✓ Branch 603 taken 28037 times.
✗ Branch 604 not taken.
✗ Branch 605 not taken.
✗ Branch 606 not taken.
✗ Branch 607 not taken.
✗ Branch 608 not taken.
✓ Branch 609 taken 1046835 times.
✗ Branch 610 not taken.
✗ Branch 611 not taken.
✗ Branch 612 not taken.
✗ Branch 613 not taken.
✗ Branch 614 not taken.
✗ Branch 615 not taken.
✓ Branch 616 taken 3 times.
✗ Branch 617 not taken.
✓ Branch 618 taken 4414 times.
✓ Branch 619 taken 788 times.
✗ Branch 620 not taken.
✓ Branch 621 taken 321 times.
✓ Branch 622 taken 94 times.
✓ Branch 623 taken 1181 times.
✓ Branch 624 taken 4183 times.
✓ Branch 625 taken 7068 times.
✓ Branch 626 taken 2 times.
✓ Branch 627 taken 1094 times.
✗ Branch 628 not taken.
✗ Branch 629 not taken.
✓ Branch 630 taken 1020506 times.
✓ Branch 631 taken 10539 times.
✓ Branch 632 taken 10539 times.
✓ Branch 633 taken 8696 times.
✓ Branch 634 taken 4912 times.
✗ Branch 635 not taken.
✗ Branch 636 not taken.
✓ Branch 637 taken 2614735 times.
✗ Branch 638 not taken.
✗ Branch 639 not taken.
✗ Branch 640 not taken.
✗ Branch 641 not taken.
✗ Branch 642 not taken.
✗ Branch 643 not taken.
✗ Branch 644 not taken.
✗ Branch 645 not taken.
✗ Branch 646 not taken.
✗ Branch 647 not taken.
✗ Branch 648 not taken.
✗ Branch 649 not taken.
✗ Branch 650 not taken.
✗ Branch 651 not taken.
✗ Branch 652 not taken.
✗ Branch 653 not taken.
✓ Branch 654 taken 1 times.
✗ Branch 655 not taken.
✓ Branch 656 taken 1 times.
✗ Branch 657 not taken.
✗ Branch 658 not taken.
✗ Branch 659 not taken.
✗ Branch 660 not taken.
✗ Branch 661 not taken.
✗ Branch 662 not taken.
✓ Branch 663 taken 26 times.
✓ Branch 664 taken 88964 times.
✓ Branch 665 taken 88964 times.
✓ Branch 666 taken 88970 times.
✓ Branch 667 taken 88970 times.
✓ Branch 668 taken 2705905 times.
✓ Branch 669 taken 8 times.
✗ Branch 670 not taken.
✗ Branch 671 not taken.
✗ Branch 672 not taken.
✗ Branch 673 not taken.
✓ Branch 674 taken 131 times.
✓ Branch 675 taken 64 times.
✗ Branch 676 not taken.
✗ Branch 677 not taken.
✗ Branch 678 not taken.
✗ Branch 679 not taken.
✗ Branch 680 not taken.
✗ Branch 681 not taken.
✗ Branch 682 not taken.
✗ Branch 683 not taken.
✗ Branch 684 not taken.
✗ Branch 685 not taken.
✗ Branch 686 not taken.
✓ Branch 687 taken 3 times.
✗ Branch 688 not taken.
✓ Branch 689 taken 394 times.
✗ Branch 690 not taken.
✗ Branch 691 not taken.
✗ Branch 692 not taken.
✗ Branch 693 not taken.
✗ Branch 694 not taken.
✓ Branch 695 taken 649 times.
✗ Branch 696 not taken.
✗ Branch 697 not taken.
✗ Branch 698 not taken.
✗ Branch 699 not taken.
✗ Branch 700 not taken.
✗ Branch 701 not taken.
✗ Branch 702 not taken.
✗ Branch 703 not taken.
✗ Branch 704 not taken.
✗ Branch 705 not taken.
✗ Branch 706 not taken.
✗ Branch 707 not taken.
✓ Branch 708 taken 120341 times.
✓ Branch 709 taken 6481 times.
✗ Branch 710 not taken.
✓ Branch 711 taken 3560 times.
✗ Branch 712 not taken.
✓ Branch 713 taken 81346 times.
✗ Branch 714 not taken.
✓ Branch 715 taken 5356632 times.
✓ Branch 716 taken 5344380 times.
✓ Branch 717 taken 32221 times.
✓ Branch 718 taken 760 times.
✗ Branch 719 not taken.
✗ Branch 720 not taken.
✗ Branch 721 not taken.
✗ Branch 722 not taken.
✗ Branch 723 not taken.
✗ Branch 724 not taken.
✗ Branch 725 not taken.
✗ Branch 726 not taken.
✗ Branch 727 not taken.
✗ Branch 728 not taken.
✗ Branch 729 not taken.
✗ Branch 730 not taken.
✗ Branch 731 not taken.
✗ Branch 732 not taken.
✗ Branch 733 not taken.
✗ Branch 734 not taken.
✗ Branch 735 not taken.
✗ Branch 736 not taken.
✗ Branch 737 not taken.
✗ Branch 738 not taken.
✗ Branch 739 not taken.
✗ Branch 740 not taken.
✗ Branch 741 not taken.
✗ Branch 742 not taken.
✗ Branch 743 not taken.
✗ Branch 744 not taken.
✗ Branch 745 not taken.
✗ Branch 746 not taken.
✗ Branch 747 not taken.
✗ Branch 748 not taken.
✗ Branch 749 not taken.
✗ Branch 750 not taken.
✗ Branch 751 not taken.
✗ Branch 752 not taken.
✗ Branch 753 not taken.
✗ Branch 754 not taken.
✓ Branch 755 taken 128 times.
✓ Branch 756 taken 128 times.
✓ Branch 757 taken 128 times.
✗ Branch 758 not taken.
✗ Branch 759 not taken.
✗ Branch 760 not taken.
✗ Branch 761 not taken.
✓ Branch 762 taken 5 times.
✓ Branch 763 taken 5 times.
✗ Branch 764 not taken.
✗ Branch 765 not taken.
✗ Branch 766 not taken.
✗ Branch 767 not taken.
✗ Branch 768 not taken.
✗ Branch 769 not taken.
✗ Branch 770 not taken.
✗ Branch 771 not taken.
✗ Branch 772 not taken.
✗ Branch 773 not taken.
✗ Branch 774 not taken.
✗ Branch 775 not taken.
✗ Branch 776 not taken.
✗ Branch 777 not taken.
✗ Branch 778 not taken.
✗ Branch 779 not taken.
✗ Branch 780 not taken.
✗ Branch 781 not taken.
✗ Branch 782 not taken.
✗ Branch 783 not taken.
✗ Branch 784 not taken.
✗ Branch 785 not taken.
✗ Branch 786 not taken.
✗ Branch 787 not taken.
✗ Branch 788 not taken.
✗ Branch 789 not taken.
✗ Branch 790 not taken.
✗ Branch 791 not taken.
✗ Branch 792 not taken.
✗ Branch 793 not taken.
✗ Branch 794 not taken.
✓ Branch 795 taken 14277 times.
✗ Branch 796 not taken.
✓ Branch 797 taken 27297 times.
✓ Branch 798 taken 531 times.
✗ Branch 799 not taken.
✓ Branch 800 taken 4 times.
✓ Branch 801 taken 3579 times.
✗ Branch 802 not taken.
✓ Branch 803 taken 11 times.
✗ Branch 804 not taken.
✗ Branch 805 not taken.
✗ Branch 806 not taken.
✗ Branch 807 not taken.
✗ Branch 808 not taken.
✗ Branch 809 not taken.
✗ Branch 810 not taken.
✗ Branch 811 not taken.
✗ Branch 812 not taken.
✓ Branch 813 taken 17 times.
✗ Branch 814 not taken.
✗ Branch 815 not taken.
✗ Branch 816 not taken.
✗ Branch 817 not taken.
✗ Branch 818 not taken.
✗ Branch 819 not taken.
✗ Branch 820 not taken.
✗ Branch 821 not taken.
✗ Branch 822 not taken.
✗ Branch 823 not taken.
✗ Branch 824 not taken.
✗ Branch 825 not taken.
✗ Branch 826 not taken.
✗ Branch 827 not taken.
✗ Branch 828 not taken.
✗ Branch 829 not taken.
✗ Branch 830 not taken.
✗ Branch 831 not taken.
✗ Branch 832 not taken.
✗ Branch 833 not taken.
✗ Branch 834 not taken.
✗ Branch 835 not taken.
✗ Branch 836 not taken.
✗ Branch 837 not taken.
✗ Branch 838 not taken.
✗ Branch 839 not taken.
✗ Branch 840 not taken.
✗ Branch 841 not taken.
✗ Branch 842 not taken.
✗ Branch 843 not taken.
✗ Branch 844 not taken.
✗ Branch 845 not taken.
✗ Branch 846 not taken.
✗ Branch 847 not taken.
✗ Branch 848 not taken.
✗ Branch 849 not taken.
✗ Branch 850 not taken.
✗ Branch 851 not taken.
✗ Branch 852 not taken.
✗ Branch 853 not taken.
✗ Branch 854 not taken.
✗ Branch 855 not taken.
✗ Branch 856 not taken.
✗ Branch 857 not taken.
✗ Branch 858 not taken.
✗ Branch 859 not taken.
✗ Branch 860 not taken.
✗ Branch 861 not taken.
✗ Branch 862 not taken.
✗ Branch 863 not taken.
✗ Branch 864 not taken.
✗ Branch 865 not taken.
✗ Branch 866 not taken.
✗ Branch 867 not taken.
✗ Branch 868 not taken.
✗ Branch 869 not taken.
✗ Branch 870 not taken.
✗ Branch 871 not taken.
✗ Branch 872 not taken.
✗ Branch 873 not taken.
✗ Branch 874 not taken.
✗ Branch 875 not taken.
✗ Branch 876 not taken.
✗ Branch 877 not taken.
✗ Branch 878 not taken.
✗ Branch 879 not taken.
✗ Branch 880 not taken.
✗ Branch 881 not taken.
✗ Branch 882 not taken.
✗ Branch 883 not taken.
✗ Branch 884 not taken.
✗ Branch 885 not taken.
✗ Branch 886 not taken.
✗ Branch 887 not taken.
✗ Branch 888 not taken.
✗ Branch 889 not taken.
✗ Branch 890 not taken.
✗ Branch 891 not taken.
✗ Branch 892 not taken.
✗ Branch 893 not taken.
✗ Branch 894 not taken.
✗ Branch 895 not taken.
✗ Branch 896 not taken.
✗ Branch 897 not taken.
✗ Branch 898 not taken.
✗ Branch 899 not taken.
✗ Branch 900 not taken.
✗ Branch 901 not taken.
✗ Branch 902 not taken.
✗ Branch 903 not taken.
✗ Branch 904 not taken.
✗ Branch 905 not taken.
✗ Branch 906 not taken.
✗ Branch 907 not taken.
✗ Branch 908 not taken.
✗ Branch 909 not taken.
✗ Branch 910 not taken.
✗ Branch 911 not taken.
✗ Branch 912 not taken.
✗ Branch 913 not taken.
✓ Branch 914 taken 80782 times.
✓ Branch 915 taken 2497 times.
✓ Branch 916 taken 56174 times.
✗ Branch 917 not taken.
✗ Branch 918 not taken.
✗ Branch 919 not taken.
✗ Branch 920 not taken.
✗ Branch 921 not taken.
✗ Branch 922 not taken.
✗ Branch 923 not taken.
✗ Branch 924 not taken.
✗ Branch 925 not taken.
✗ Branch 926 not taken.
✗ Branch 927 not taken.
✗ Branch 928 not taken.
✗ Branch 929 not taken.
✗ Branch 930 not taken.
✗ Branch 931 not taken.
✗ Branch 932 not taken.
✗ Branch 933 not taken.
✗ Branch 934 not taken.
✗ Branch 935 not taken.
✗ Branch 936 not taken.
✗ Branch 937 not taken.
✗ Branch 938 not taken.
✗ Branch 939 not taken.
✗ Branch 940 not taken.
✗ Branch 941 not taken.
✗ Branch 942 not taken.
✗ Branch 943 not taken.
✗ Branch 944 not taken.
✗ Branch 945 not taken.
✗ Branch 946 not taken.
✗ Branch 947 not taken.
✗ Branch 948 not taken.
✗ Branch 949 not taken.
✗ Branch 950 not taken.
✗ Branch 951 not taken.
✗ Branch 952 not taken.
✗ Branch 953 not taken.
✓ Branch 954 taken 3225 times.
✗ Branch 955 not taken.
✗ Branch 956 not taken.
✗ Branch 957 not taken.
✗ Branch 958 not taken.
✗ Branch 959 not taken.
✗ Branch 960 not taken.
✗ Branch 961 not taken.
✗ Branch 962 not taken.
✗ Branch 963 not taken.
✗ Branch 964 not taken.
✗ Branch 965 not taken.
✗ Branch 966 not taken.
✗ Branch 967 not taken.
✗ Branch 968 not taken.
✗ Branch 969 not taken.
✗ Branch 970 not taken.
✗ Branch 971 not taken.
✗ Branch 972 not taken.
✗ Branch 973 not taken.
✗ Branch 974 not taken.
✗ Branch 975 not taken.
✗ Branch 976 not taken.
✗ Branch 977 not taken.
✗ Branch 978 not taken.
✗ Branch 979 not taken.
✗ Branch 980 not taken.
✗ Branch 981 not taken.
✗ Branch 982 not taken.
✗ Branch 983 not taken.
✗ Branch 984 not taken.
✗ Branch 985 not taken.
✗ Branch 986 not taken.
✗ Branch 987 not taken.
✗ Branch 988 not taken.
✗ Branch 989 not taken.
✗ Branch 990 not taken.
✗ Branch 991 not taken.
✗ Branch 992 not taken.
✗ Branch 993 not taken.
✗ Branch 994 not taken.
✗ Branch 995 not taken.
✗ Branch 996 not taken.
✗ Branch 997 not taken.
✗ Branch 998 not taken.
✗ Branch 999 not taken.
✗ Branch 1000 not taken.
✗ Branch 1001 not taken.
✗ Branch 1002 not taken.
✗ Branch 1003 not taken.
✗ Branch 1004 not taken.
✗ Branch 1005 not taken.
✗ Branch 1006 not taken.
✗ Branch 1007 not taken.
✗ Branch 1008 not taken.
✗ Branch 1009 not taken.
✗ Branch 1010 not taken.
✗ Branch 1011 not taken.
✗ Branch 1012 not taken.
✗ Branch 1013 not taken.
✗ Branch 1014 not taken.
✗ Branch 1015 not taken.
✗ Branch 1016 not taken.
✗ Branch 1017 not taken.
✗ Branch 1018 not taken.
✗ Branch 1019 not taken.
✗ Branch 1020 not taken.
✗ Branch 1021 not taken.
✗ Branch 1022 not taken.
✗ Branch 1023 not taken.
✗ Branch 1024 not taken.
✗ Branch 1025 not taken.
✗ Branch 1026 not taken.
✗ Branch 1027 not taken.
✗ Branch 1028 not taken.
✗ Branch 1029 not taken.
✗ Branch 1030 not taken.
✗ Branch 1031 not taken.
✗ Branch 1032 not taken.
✗ Branch 1033 not taken.
✗ Branch 1034 not taken.
✗ Branch 1035 not taken.
✗ Branch 1036 not taken.
✗ Branch 1037 not taken.
✗ Branch 1038 not taken.
✗ Branch 1039 not taken.
✗ Branch 1040 not taken.
✗ Branch 1041 not taken.
✗ Branch 1042 not taken.
✗ Branch 1043 not taken.
✗ Branch 1044 not taken.
✗ Branch 1045 not taken.
✗ Branch 1046 not taken.
✗ Branch 1047 not taken.
✗ Branch 1048 not taken.
✗ Branch 1049 not taken.
✗ Branch 1050 not taken.
✗ Branch 1051 not taken.
✗ Branch 1052 not taken.
✗ Branch 1053 not taken.
✗ Branch 1054 not taken.
✗ Branch 1055 not taken.
✗ Branch 1056 not taken.
✗ Branch 1057 not taken.
✗ Branch 1058 not taken.
✗ Branch 1059 not taken.
✗ Branch 1060 not taken.
✗ Branch 1061 not taken.
✗ Branch 1062 not taken.
✗ Branch 1063 not taken.
✗ Branch 1064 not taken.
✗ Branch 1065 not taken.
✗ Branch 1066 not taken.
✗ Branch 1067 not taken.
✗ Branch 1068 not taken.
✗ Branch 1069 not taken.
✗ Branch 1070 not taken.
✗ Branch 1071 not taken.
✗ Branch 1072 not taken.
✗ Branch 1073 not taken.
✗ Branch 1074 not taken.
✗ Branch 1075 not taken.
✗ Branch 1076 not taken.
✗ Branch 1077 not taken.
✗ Branch 1078 not taken.
✗ Branch 1079 not taken.
✗ Branch 1080 not taken.
✗ Branch 1081 not taken.
✗ Branch 1082 not taken.
✗ Branch 1083 not taken.
✗ Branch 1084 not taken.
✗ Branch 1085 not taken.
✗ Branch 1086 not taken.
✗ Branch 1087 not taken.
✗ Branch 1088 not taken.
✗ Branch 1089 not taken.
✗ Branch 1090 not taken.
✗ Branch 1091 not taken.
✗ Branch 1092 not taken.
✗ Branch 1093 not taken.
✗ Branch 1094 not taken.
✗ Branch 1095 not taken.
✗ Branch 1096 not taken.
✗ Branch 1097 not taken.
✗ Branch 1098 not taken.
✗ Branch 1099 not taken.
✗ Branch 1100 not taken.
✗ Branch 1101 not taken.
✗ Branch 1102 not taken.
✗ Branch 1103 not taken.
✗ Branch 1104 not taken.
✗ Branch 1105 not taken.
✗ Branch 1106 not taken.
✗ Branch 1107 not taken.
✗ Branch 1108 not taken.
✗ Branch 1109 not taken.
✗ Branch 1110 not taken.
✗ Branch 1111 not taken.
✗ Branch 1112 not taken.
✗ Branch 1113 not taken.
✗ Branch 1114 not taken.
✗ Branch 1115 not taken.
✗ Branch 1116 not taken.
✗ Branch 1117 not taken.
✗ Branch 1118 not taken.
✗ Branch 1119 not taken.
✗ Branch 1120 not taken.
✗ Branch 1121 not taken.
✗ Branch 1122 not taken.
✗ Branch 1123 not taken.
✗ Branch 1124 not taken.
✗ Branch 1125 not taken.
✗ Branch 1126 not taken.
✗ Branch 1127 not taken.
✗ Branch 1128 not taken.
✗ Branch 1129 not taken.
✗ Branch 1130 not taken.
✗ Branch 1131 not taken.
✗ Branch 1132 not taken.
✗ Branch 1133 not taken.
✗ Branch 1134 not taken.
✗ Branch 1135 not taken.
✗ Branch 1136 not taken.
✗ Branch 1137 not taken.
✗ Branch 1138 not taken.
✗ Branch 1139 not taken.
✗ Branch 1140 not taken.
✗ Branch 1141 not taken.
✗ Branch 1142 not taken.
✗ Branch 1143 not taken.
✗ Branch 1144 not taken.
✗ Branch 1145 not taken.
✗ Branch 1146 not taken.
✗ Branch 1147 not taken.
✗ Branch 1148 not taken.
✗ Branch 1149 not taken.
✗ Branch 1150 not taken.
✗ Branch 1151 not taken.
✗ Branch 1152 not taken.
✗ Branch 1153 not taken.
✗ Branch 1154 not taken.
✗ Branch 1155 not taken.
✗ Branch 1156 not taken.
✗ Branch 1157 not taken.
✗ Branch 1158 not taken.
✗ Branch 1159 not taken.
✗ Branch 1160 not taken.
✗ Branch 1161 not taken.
✗ Branch 1162 not taken.
✗ Branch 1163 not taken.
✗ Branch 1164 not taken.
✗ Branch 1165 not taken.
✗ Branch 1166 not taken.
✗ Branch 1167 not taken.
✗ Branch 1168 not taken.
✗ Branch 1169 not taken.
✗ Branch 1170 not taken.
✗ Branch 1171 not taken.
✗ Branch 1172 not taken.
✗ Branch 1173 not taken.
✗ Branch 1174 not taken.
✗ Branch 1175 not taken.
✓ Branch 1176 taken 409929 times.
✓ Branch 1177 taken 18561592 times.
✗ Branch 1178 not taken.
✓ Branch 1179 taken 64 times.
✓ Branch 1180 taken 265857 times.
✗ Branch 1181 not taken.
✓ Branch 1182 taken 806953 times.
✗ Branch 1183 not taken.
✗ Branch 1184 not taken.
✗ Branch 1185 not taken.
✗ Branch 1186 not taken.
✗ Branch 1187 not taken.
✓ Branch 1188 taken 142 times.
✗ Branch 1189 not taken.
✗ Branch 1190 not taken.
✗ Branch 1191 not taken.
✗ Branch 1192 not taken.
✗ Branch 1193 not taken.
✗ Branch 1194 not taken.
✗ Branch 1195 not taken.
✗ Branch 1196 not taken.
✓ Branch 1197 taken 284 times.
✗ Branch 1198 not taken.
✗ Branch 1199 not taken.
✗ Branch 1200 not taken.
✗ Branch 1201 not taken.
✗ Branch 1202 not taken.
✗ Branch 1203 not taken.
✓ Branch 1204 taken 58 times.
✗ Branch 1205 not taken.
✗ Branch 1206 not taken.
✓ Branch 1207 taken 74 times.
✗ Branch 1208 not taken.
✗ Branch 1209 not taken.
✗ Branch 1210 not taken.
✗ Branch 1211 not taken.
✗ Branch 1212 not taken.
✗ Branch 1213 not taken.
✗ Branch 1214 not taken.
✗ Branch 1215 not taken.
✗ Branch 1216 not taken.
✗ Branch 1217 not taken.
✗ Branch 1218 not taken.
✗ Branch 1219 not taken.
✗ Branch 1220 not taken.
✗ Branch 1221 not taken.
✗ Branch 1222 not taken.
✗ Branch 1223 not taken.
✗ Branch 1224 not taken.
✗ Branch 1225 not taken.
✗ Branch 1226 not taken.
✗ Branch 1227 not taken.
✗ Branch 1228 not taken.
✗ Branch 1229 not taken.
✗ Branch 1230 not taken.
✗ Branch 1231 not taken.
✗ Branch 1232 not taken.
✗ Branch 1233 not taken.
✗ Branch 1234 not taken.
✗ Branch 1235 not taken.
✗ Branch 1236 not taken.
✗ Branch 1237 not taken.
✗ Branch 1238 not taken.
✗ Branch 1239 not taken.
✗ Branch 1240 not taken.
✗ Branch 1241 not taken.
✗ Branch 1242 not taken.
✗ Branch 1243 not taken.
✗ Branch 1244 not taken.
✗ Branch 1245 not taken.
✗ Branch 1246 not taken.
✗ Branch 1247 not taken.
✗ Branch 1248 not taken.
✗ Branch 1249 not taken.
✗ Branch 1250 not taken.
✗ Branch 1251 not taken.
✗ Branch 1252 not taken.
✗ Branch 1253 not taken.
✗ Branch 1254 not taken.
✗ Branch 1255 not taken.
✗ Branch 1256 not taken.
✗ Branch 1257 not taken.
✗ Branch 1258 not taken.
✗ Branch 1259 not taken.
✗ Branch 1260 not taken.
✗ Branch 1261 not taken.
✗ Branch 1262 not taken.
✗ Branch 1263 not taken.
✗ Branch 1264 not taken.
✗ Branch 1265 not taken.
✗ Branch 1266 not taken.
✗ Branch 1267 not taken.
✗ Branch 1268 not taken.
✗ Branch 1269 not taken.
✗ Branch 1270 not taken.
✗ Branch 1271 not taken.
✗ Branch 1272 not taken.
✗ Branch 1273 not taken.
✗ Branch 1274 not taken.
✗ Branch 1275 not taken.
✗ Branch 1276 not taken.
✗ Branch 1277 not taken.
✗ Branch 1278 not taken.
✗ Branch 1279 not taken.
✗ Branch 1280 not taken.
✗ Branch 1281 not taken.
✗ Branch 1282 not taken.
✗ Branch 1283 not taken.
✗ Branch 1284 not taken.
✗ Branch 1285 not taken.
✗ Branch 1286 not taken.
✗ Branch 1287 not taken.
✗ Branch 1288 not taken.
✗ Branch 1289 not taken.
✗ Branch 1290 not taken.
✗ Branch 1291 not taken.
✗ Branch 1292 not taken.
✗ Branch 1293 not taken.
✗ Branch 1294 not taken.
✗ Branch 1295 not taken.
✗ Branch 1296 not taken.
✗ Branch 1297 not taken.
✗ Branch 1298 not taken.
✗ Branch 1299 not taken.
✗ Branch 1300 not taken.
✗ Branch 1301 not taken.
✗ Branch 1302 not taken.
✗ Branch 1303 not taken.
✗ Branch 1304 not taken.
✗ Branch 1305 not taken.
✗ Branch 1306 not taken.
✗ Branch 1307 not taken.
✗ Branch 1308 not taken.
✗ Branch 1309 not taken.
✗ Branch 1310 not taken.
✗ Branch 1311 not taken.
✗ Branch 1312 not taken.
✗ Branch 1313 not taken.
✗ Branch 1314 not taken.
✗ Branch 1315 not taken.
✗ Branch 1316 not taken.
✗ Branch 1317 not taken.
✗ Branch 1318 not taken.
✗ Branch 1319 not taken.
✗ Branch 1320 not taken.
✗ Branch 1321 not taken.
✗ Branch 1322 not taken.
✗ Branch 1323 not taken.
✗ Branch 1324 not taken.
✗ Branch 1325 not taken.
✗ Branch 1326 not taken.
✗ Branch 1327 not taken.
✗ Branch 1328 not taken.
1401361252 switch(arg)
15896 {
15897 //debug ri->d[]
15898 case DEBUGD:
15899 {
15900 int32_t a = vbound((ri->d[rINDEX] / 10000), 0, 255);
15901 ri->d[a] = value/10000;
15902 break;
15903 }
15904
15905 ///----------------------------------------------------------------------------------------------------//
15906 //FFC Variables
15907 case DATA:
15908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2272629 times.
2272629 if(BC::checkFFC(ri->ffcref, "ffc->Data") == SH::_NoError)
15909 {
15910 2272629 tmpscr->ffcs[ri->ffcref].setData(vbound(value/10000,0,MAXCOMBOS-1));
15911 2272629 }
15912 2272629 break;
15913
15914 case FFSCRIPT:
15915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9725 times.
9725 if(BC::checkFFC(ri->ffcref, "ffc->Script") == SH::_NoError)
15916 {
15917 9725 tmpscr->ffcs[ri->ffcref].script = vbound(value/10000, 0, NUMSCRIPTFFC-1);
15918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9725 times.
9725 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
15919 {
15920
2/2
✓ Branch 0 taken 19450 times.
✓ Branch 1 taken 9725 times.
29175 for(int32_t i=0; i<2; i++)
15921 19450 tmpscr->ffcs[ri->ffcref].inita[i] = 0;
15922
15923
2/2
✓ Branch 0 taken 77800 times.
✓ Branch 1 taken 9725 times.
87525 for(int32_t i=0; i<8; i++)
15924 77800 tmpscr->ffcs[ri->ffcref].initd[i] = 0;
15925 9725 }
15926
2/2
✓ Branch 0 taken 155600 times.
✓ Branch 1 taken 9725 times.
165325 for(int32_t i=0; i<16; i++)
15927 155600 ffmisc[ri->ffcref][i] = 0;
15928
15929 9725 auto& data = get_script_engine_data(ScriptType::FFC, ri->ffcref);
15930 9725 data.ref.Clear();
15931 9725 data.initialized = false;
15932 9725 FFScript::deallocateAllScriptOwned(ScriptType::FFC, ri->ffcref);
15933 9725 }
15934 9725 break;
15935
15936
15937 case FCSET:
15938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1042466 times.
1042466 if(BC::checkFFC(ri->ffcref, "ffc->CSet") == SH::_NoError)
15939 1042466 tmpscr->ffcs[ri->ffcref].cset = (value/10000)&15;
15940 1042466 break;
15941
15942 case DELAY:
15943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2881 times.
2881 if(BC::checkFFC(ri->ffcref, "ffc->Delay") == SH::_NoError)
15944 2881 tmpscr->ffcs[ri->ffcref].delay = value/10000;
15945 2881 break;
15946
15947 case FX:
15948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1215066 times.
1215066 if(BC::checkFFC(ri->ffcref, "ffc->X") == SH::_NoError)
15949 1215066 tmpscr->ffcs[ri->ffcref].x = zslongToFix(value);
15950 1215066 break;
15951
15952 case FY:
15953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1217071 times.
1217071 if(BC::checkFFC(ri->ffcref, "ffc->Y") == SH::_NoError)
15954 1217071 tmpscr->ffcs[ri->ffcref].y=zslongToFix(value);
15955 1217071 break;
15956
15957 case XD:
15958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9445 times.
9445 if(BC::checkFFC(ri->ffcref, "ffc->Vx") == SH::_NoError)
15959 9445 tmpscr->ffcs[ri->ffcref].vx=zslongToFix(value);
15960 9445 break;
15961
15962 case YD:
15963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9429 times.
9429 if(BC::checkFFC(ri->ffcref, "ffc->Vy") == SH::_NoError)
15964 9429 tmpscr->ffcs[ri->ffcref].vy=zslongToFix(value);
15965 9429 break;
15966
15967 case FFCID:
15968 break;
15969
15970 case XD2:
15971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9173 times.
9173 if(BC::checkFFC(ri->ffcref, "ffc->Ax") == SH::_NoError)
15972 9173 tmpscr->ffcs[ri->ffcref].ax=zslongToFix(value);
15973 9173 break;
15974
15975 case YD2:
15976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9173 times.
9173 if(BC::checkFFC(ri->ffcref, "ffc->Ay") == SH::_NoError)
15977 9173 tmpscr->ffcs[ri->ffcref].ay=zslongToFix(value);
15978 9173 break;
15979
15980 case FFFLAGSD:
15981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 229040 times.
229040 if(BC::checkFFC(ri->ffcref, "ffc->Flags[]") == SH::_NoError)
15982 {
15983 229040 auto flag = 1<<((ri->d[rINDEX])/10000);
15984 229040 ffcdata& ff = tmpscr->ffcs[ri->ffcref];
15985
2/2
✓ Branch 0 taken 31751 times.
✓ Branch 1 taken 197289 times.
229040 SETFLAG(ff.flags, flag, value);
15986
4/4
✓ Branch 0 taken 225803 times.
✓ Branch 1 taken 3237 times.
✓ Branch 2 taken 3407 times.
✓ Branch 3 taken 222396 times.
229040 if (flag == ffSOLID || flag == ffCHANGER)
15987 6644 ff.updateSolid();
15988 229040 }
15989 229040 break;
15990
15991 case FFCWIDTH:
15992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3248 times.
3248 if(BC::checkFFC(ri->ffcref, "ffc->EffectWidth") == SH::_NoError)
15993 3248 tmpscr->ffcs[ri->ffcref].hit_width = (value/10000);
15994 3248 break;
15995
15996 case FFCHEIGHT:
15997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3250 times.
3250 if(BC::checkFFC(ri->ffcref, "ffc->EffectHeight") == SH::_NoError)
15998 3250 tmpscr->ffcs[ri->ffcref].hit_height = (value/10000);
15999 3250 break;
16000
16001 case FFTWIDTH:
16002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9503 times.
9503 if(BC::checkFFC(ri->ffcref, "ffc->TileWidth") == SH::_NoError)
16003 9503 tmpscr->ffcs[ri->ffcref].txsz = vbound(value/10000, 1, 4);
16004 9503 break;
16005
16006 case FFTHEIGHT:
16007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9513 times.
9513 if(BC::checkFFC(ri->ffcref, "ffc->TileHeight") == SH::_NoError)
16008 9513 tmpscr->ffcs[ri->ffcref].tysz = vbound(value/10000, 1, 4);
16009 9513 break;
16010
16011 case FFLINK:
16012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 616 times.
616 if(BC::checkFFC(ri->ffcref, "ffc->Link") == SH::_NoError)
16013 616 (tmpscr->ffcs[ri->ffcref].link)=vbound(value/10000, 0, MAXFFCS); // Allow "ffc->Link = 0" to unlink ffc.
16014 //0 is none, setting this before made it impssible to clear it. -Z
16015 616 break;
16016
16017 case FFMISCD:
16018 {
16019 900 int32_t a = vbound(ri->d[rINDEX]/10000,0,15);
16020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
900 if(BC::checkFFC(ri->ffcref, "ffc->Misc[]")== SH::_NoError)
16021 900 ffmisc[ri->ffcref][a]=value;
16022 900 break;
16023 }
16024
16025 case FFINITDD:
16026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17707 times.
17707 if(BC::checkFFC(ri->ffcref, "ffc->InitD[]") == SH::_NoError)
16027 17707 (tmpscr->ffcs[ri->ffcref].initd[vbound(ri->d[rINDEX]/10000,0,7)])=value;
16028 17707 break;
16029
16030 case FFCLASTCHANGERX:
16031 if(BC::checkFFC(ri->ffcref, "ffc->LastChangerX") == SH::_NoError)
16032 ffposx[ri->ffcref]=vbound(zslongToFix(value).getInt(),-32768, 32767);
16033 break;
16034
16035 case FFCLASTCHANGERY:
16036 if(BC::checkFFC(ri->ffcref, "ffc->LastChangerY") == SH::_NoError)
16037 ffposy[ri->ffcref]=vbound(zslongToFix(value).getInt(),-32768, 32767);
16038 break;
16039
16040
16041
16042 ///----------------------------------------------------------------------------------------------------//
16043 //Hero's Variables
16044 case LINKX:
16045 {
16046
2/2
✓ Branch 0 taken 1210 times.
✓ Branch 1 taken 443391 times.
444601 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
16047 {
16048 1210 Hero.setXfix(zslongToFix(value));
16049 1210 }
16050 else
16051 {
16052 443391 Hero.setX(value/10000);
16053 }
16054 }
16055 444601 break;
16056
16057 case LINKCSET:
16058 {
16059 Hero.cs = value/10000;
16060 break;
16061 }
16062 case LINKY:
16063 {
16064
2/2
✓ Branch 0 taken 1071 times.
✓ Branch 1 taken 457869 times.
458940 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
16065 {
16066 1071 Hero.setYfix(zslongToFix(value));
16067 1071 }
16068 else
16069 {
16070 457869 Hero.setY(value/10000);
16071 }
16072 }
16073 458940 break;
16074
16075 case LINKZ:
16076 {
16077
2/2
✓ Branch 0 taken 2767 times.
✓ Branch 1 taken 2 times.
2769 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
16078 {
16079 2767 Hero.setZfix(zslongToFix(value));
16080 2767 }
16081 else
16082 {
16083 2 Hero.setZ(value/10000);
16084 }
16085 }
16086 2769 break;
16087
16088 case LINKJUMP:
16089 64379 Hero.setFall(zslongToFix(value) * -100);
16090 64379 break;
16091
16092 case HEROFAKEJUMP:
16093 Hero.setFakeFall(zslongToFix(value) * -100);
16094 break;
16095
16096 case LINKDIR:
16097 {
16098 //Hero->setDir() calls reset_hookshot(), which removes the sword sprite.. O_o
16099
3/4
✓ Branch 0 taken 93219 times.
✓ Branch 1 taken 475 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93219 times.
93694 if(Hero.getAction() == attacking || Hero.getAction() == sideswimattacking) Hero.dir = (value/10000);
16100 93219 else Hero.setDir(value/10000);
16101
16102 93694 break;
16103 }
16104
16105 case LINKHITDIR:
16106 Hero.setHitDir(value / 10000);
16107 break;
16108
16109 case LINKGRAVITY:
16110 if(value)
16111 Hero.moveflags |= FLAG_OBEYS_GRAV;
16112 else
16113 Hero.moveflags &= ~FLAG_OBEYS_GRAV;
16114 break;
16115
16116 case HERONOSTEPFORWARD:
16117 FFCore.nostepforward = ( (value) ? 1 : 0 );
16118 break;
16119
16120 case LINKHP:
16121
6/6
✓ Branch 0 taken 174180 times.
✓ Branch 1 taken 96374 times.
✓ Branch 2 taken 270406 times.
✓ Branch 3 taken 148 times.
✓ Branch 4 taken 174032 times.
✓ Branch 5 taken 96374 times.
270554 game->set_life(zc_max(0, zc_min(value/10000,game->get_maxlife())));
16122 270554 break;
16123
16124 case LINKMP:
16125
6/6
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 5754 times.
✓ Branch 2 taken 10401 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 4647 times.
✓ Branch 5 taken 5754 times.
10416 game->set_magic(zc_max(0, zc_min(value/10000,game->get_maxmagic())));
16126 10416 break;
16127
16128 case LINKMAXHP:
16129 56 game->set_maxlife(value/10000);
16130 56 break;
16131
16132 case LINKMAXMP:
16133 game->set_maxmagic(value/10000);
16134 break;
16135
16136 case LINKACTION:
16137 {
16138 388 int32_t act = value / 10000;
16139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 388 times.
388 switch(act)
16140 {
16141 case hookshotout:
16142 case stunned:
16143 case ispushing:
16144 FFCore.setHeroAction(act);
16145 break;
16146 default:
16147 388 Hero.setAction((actiontype)(act));
16148 388 }
16149 //Protect from writing illegal actions to Hero's raw variable.
16150 //in the future, we can move all scripted actions that are not possible
16151 //to set in ZC into this mechanic. -Z
16152 388 break;
16153 }
16154
16155 case HEROHEALTHBEEP:
16156 {
16157 int32_t beep = vbound((value/10000),-4, 255);
16158 //-2 suspends system control of stopping the sound
16159 //-3 suspends system control of stopping the sound AND suspends
16160 // system control over starting or playing it.
16161 heart_beep_timer = beep;
16162 if ( heart_beep_timer > -1 )
16163 {
16164 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
16165 }
16166 else
16167 {
16168 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
16169 }
16170 break;
16171 }
16172
16173 case LINKHELD:
16174 Hero.setHeldItem(vbound(value/10000,0,MAXITEMS-1));
16175 break;
16176
16177 case HEROSTEPS:
16178 {
16179 lsteps[vbound(ri->d[rINDEX]/10000,0,7)] = value/10000;
16180 break;
16181 }
16182
16183 case HEROSTEPRATE:
16184 if(!get_qr(qr_NEW_HERO_MOVEMENT))
16185 {
16186 Z_scripterrlog("To use '%s', you must %s the quest rule '%s'.", "Hero->Step", "enable", "New Player Movement");
16187 }
16188 Hero.setStepRate(zc_max(value/10000,0));
16189 if(!get_qr(qr_SCRIPT_WRITING_HEROSTEP_DOESNT_CARRY_OVER))
16190 zinit.heroStep = Hero.getStepRate();
16191 break;
16192 case HEROSHOVEOFFSET:
16193 if(!get_qr(qr_NEW_HERO_MOVEMENT2))
16194 Z_scripterrlog("To use 'Hero->ShoveOffset', you must enable the quest rule 'Newer Player Movement'.");
16195 Hero.shove_offset = vbound(zslongToFix(value),16_zf,0_zf);
16196 if(!get_qr(qr_SCRIPT_WRITING_HEROSTEP_DOESNT_CARRY_OVER))
16197 zinit.shove_offset = Hero.shove_offset;
16198 break;
16199
16200 case LINKITEMD:
16201 {
16202 5906 int32_t itemID=vbound(ri->d[rINDEX]/10000,0,MAXITEMS-1);
16203
16204 // If the Cane of Byrna is being removed, cancel its effect.
16205
3/4
✓ Branch 0 taken 3219 times.
✓ Branch 1 taken 2687 times.
✓ Branch 2 taken 3219 times.
✗ Branch 3 not taken.
5906 if(value==0 && itemID==current_item_id(itype_cbyrna))
16206 stopCaneOfByrna();
16207
16208 5906 auto& data = get_script_engine_data(ScriptType::Item, itemID);
16209
16210 //Stop current script if set false.
16211
4/4
✓ Branch 0 taken 3219 times.
✓ Branch 1 taken 2687 times.
✓ Branch 2 taken 3203 times.
✓ Branch 3 taken 16 times.
5906 if ( !value && data.doscript )
16212 {
16213 16 data.doscript = 4; //Val of 4 means 'clear stack and quit'
16214 //itemScriptData[itemID].Clear(); //Don't clear here, causes crash if is current item!
16215 16 }
16216
4/4
✓ Branch 0 taken 2687 times.
✓ Branch 1 taken 3203 times.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 2645 times.
5890 else if ( value && !data.doscript )
16217 {
16218 //Clear the item refInfo and stack for use.
16219 2645 data.ref.Clear();
16220
1/2
✓ Branch 0 taken 2645 times.
✗ Branch 1 not taken.
2645 if ( (itemsbuf[itemID].flags&ITEM_PASSIVESCRIPT) ) data.doscript = 1;
16221 2645 }
16222
3/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 3203 times.
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
3245 else if ( value && data.doscript == 4 )
16223 {
16224 // Arbitrary event number 49326: Writing the item false, then true, in the same frame. -Z
16225 if ( (itemsbuf[itemID].flags&ITEM_PASSIVESCRIPT) ) data.doscript = 1;
16226 }
16227
16228 5906 bool settrue = ( value != 0 );
16229
16230 //Sanity check to prevent setting the item if the value would be the same. -Z
16231
2/2
✓ Branch 0 taken 3834 times.
✓ Branch 1 taken 2072 times.
5906 if ( game->item[itemID] != settrue )
16232 {
16233 2072 game->set_item(itemID,(value != 0));
16234 2072 }
16235
16236
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5906 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5906 if((get_qr(qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
16237 {
16238 5906 ringcolor(false);
16239 //refreshpal=true;
16240 5906 }
16241
2/2
✓ Branch 0 taken 2687 times.
✓ Branch 1 taken 3219 times.
5906 if ( !value ) //setting the item false clears the state of forced ->Equipment writes.
16242 {
16243
1/2
✓ Branch 0 taken 3219 times.
✗ Branch 1 not taken.
3219 if ( game->forced_bwpn == itemID )
16244 {
16245 game->forced_bwpn = -1;
16246 } //not else if! -Z
16247
2/2
✓ Branch 0 taken 3218 times.
✓ Branch 1 taken 1 times.
3219 if ( game->forced_awpn == itemID )
16248 {
16249 1 game->forced_awpn = -1;
16250 1 }
16251
2/2
✓ Branch 0 taken 3216 times.
✓ Branch 1 taken 3 times.
3219 if ( game->forced_xwpn == itemID )
16252 {
16253 3 game->forced_xwpn = -1;
16254 3 }
16255
2/2
✓ Branch 0 taken 3216 times.
✓ Branch 1 taken 3 times.
3219 if ( game->forced_ywpn == itemID )
16256 {
16257 3 game->forced_ywpn = -1;
16258 3 }
16259 3219 }
16260 }
16261 5906 break;
16262
16263 case LINKEQUIP:
16264 {
16265 if ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) < 33 )
16266 {
16267 break;
16268 }
16269 //int32_t seta = (value/10000) >> 8; int32_t setb = value/10000) & 0xFF;
16270 int32_t setb = ((value/10000)&0xFF00)>>8, seta = (value/10000)&0xFF;
16271 seta = vbound(seta,-1,255);
16272 setb = vbound(setb,-1,255);
16273 //zprint("A is: %d\n", seta);
16274 //zprint("A is: %d\n", setb);
16275
16276 Awpn = seta;
16277 game->awpn = 255;
16278 game->forced_awpn = seta;
16279 game->items_off[seta] = 0;
16280 directItemA = seta;
16281
16282 Bwpn = setb;
16283 game->bwpn = 255;
16284 game->forced_bwpn = setb;
16285 game->items_off[setb] = 0;
16286 directItemB = setb;
16287 break;
16288 }
16289
16290
16291 case SETITEMSLOT:
16292 {
16293 //ri->d[rINDEX2] = 1st arg
16294 //ri->d[rINDEX] = 2nd arg
16295 //value = third arg
16296 //int32_t item, int32_t slot, int32_t force
16297 int32_t itm = ri->d[rINDEX]/10000;
16298 itm = vbound(itm, -1, 255);
16299
16300 int32_t slot = ri->d[rINDEX2]/10000;
16301 int32_t force = ri->d[rEXP1]/10000;
16302
16303 zprint("SetItemSlot rid->[0] is (%i), trying to use for '%s'\n", itm, "itm");
16304 zprint("SetItemSlot rid->[1] is (%i), trying to use for '%s'\n", slot, "slot");
16305 zprint("SetItemSlot rid->[2] is (%i), trying to use for '%s'\n", force, "force");
16306
16307 //If we add more item buttons, slot should be an int32_t
16308 //and force shuld be an int32_t
16309
16310 /*
16311 For zScript,
16312 const int32_t ITM_REQUIRE_NONE = 0
16313 const int32_t ITM_REQUIRE_INVENTORY = 1
16314 const int32_t ITM_REQUIRE_A_SLOT_RULE = 2
16315 //Combine as flags
16316 */
16317 if ( force == 0 )
16318 {
16319 switch(slot)
16320 {
16321 case 0: //b
16322 Bwpn = itm;
16323 game->items_off[itm] = 0;
16324 game->bwpn = 255;
16325 game->forced_bwpn = itm;
16326 directItemB = itm;
16327 break;
16328
16329 case 1: //a
16330 Awpn = itm;
16331 game->items_off[itm] = 0;
16332 game->awpn = 255;
16333 game->forced_awpn = itm;
16334 directItemA = itm;
16335 break;
16336
16337 case 2: //x
16338 Xwpn = itm;
16339 game->items_off[itm] = 0;
16340 game->xwpn = 255;
16341 game->forced_xwpn = itm;
16342 directItemX = itm;
16343 break;
16344
16345 case 3: //y
16346 Ywpn = itm;
16347 game->items_off[itm] = 0;
16348 game->ywpn = 255;
16349 game->forced_ywpn = itm;
16350 directItemX = itm;
16351 break;
16352 }
16353 }
16354 else if ( force == 1 )
16355 {
16356 if (game->item[itm])
16357 {
16358 switch(slot)
16359 {
16360 case 0: //b
16361 Bwpn = itm;
16362 game->items_off[itm] = 0;
16363 game->bwpn = 255;
16364 game->forced_bwpn = itm;
16365 directItemB = itm;
16366 break;
16367
16368 case 1: //a
16369 Awpn = itm;
16370 game->items_off[itm] = 0;
16371 game->awpn = 255;
16372 game->forced_awpn = itm;
16373 directItemA = itm;
16374 break;
16375
16376 case 2: //x
16377 Xwpn = itm;
16378 game->items_off[itm] = 0;
16379 game->xwpn = 255;
16380 game->forced_xwpn = itm;
16381 directItemX = itm;
16382 break;
16383
16384 case 3: //y
16385 Ywpn = itm;
16386 game->items_off[itm] = 0;
16387 game->ywpn = 255;
16388 game->forced_ywpn = itm;
16389 directItemY = itm;
16390 break;
16391 }
16392 }
16393 }
16394 else if ( force == 2 )
16395 {
16396 switch(slot)
16397 {
16398 case 0: //b
16399 Bwpn = itm;
16400 game->items_off[itm] = 0;
16401 game->bwpn = 255;
16402 game->forced_bwpn = itm;
16403 directItemB = itm;
16404 break;
16405
16406 case 1: //a
16407 if (get_qr(qr_SELECTAWPN))
16408 {
16409 Awpn = itm;
16410 game->items_off[itm] = 0;
16411 game->awpn = 255;
16412 game->forced_awpn = itm;
16413 directItemA = itm;
16414 }
16415 break;
16416
16417 case 2: //x
16418 Xwpn = itm;
16419 game->items_off[itm] = 0;
16420 game->xwpn = 255;
16421 game->forced_xwpn = itm;
16422 directItemX = itm;
16423 break;
16424
16425 case 3: //y
16426 Ywpn = itm;
16427 game->items_off[itm] = 0;
16428 game->ywpn = 255;
16429 game->forced_ywpn = itm;
16430 directItemY = itm;
16431 break;
16432 }
16433 }
16434 else if ( force == 3 ) //Flag ITM_REQUIRE_INVENTORY + ITM_REQUIRE_SLOT_A_RULE
16435 {
16436 if ( game->item[itm] )
16437 {
16438 switch(slot)
16439 {
16440 case 0: //b
16441 Bwpn = itm;
16442 game->items_off[itm] = 0;
16443 game->bwpn = 255;
16444 game->forced_bwpn = itm;
16445 directItemB = itm;
16446 break;
16447
16448 case 1: //a
16449 if (get_qr(qr_SELECTAWPN))
16450 {
16451 Awpn = itm;
16452 game->items_off[itm] = 0;
16453 game->awpn = 255;
16454 game->forced_awpn = itm;
16455 directItemA = itm;
16456 }
16457 break;
16458
16459 case 2: //x
16460 Xwpn = itm;
16461 game->items_off[itm] = 0;
16462 game->xwpn = 255;
16463 game->forced_xwpn = itm;
16464 directItemX = itm;
16465 break;
16466
16467 case 3: //y
16468 Ywpn = itm;
16469 game->items_off[itm] = 0;
16470 game->ywpn = 255;
16471 game->forced_ywpn = itm;
16472 directItemY = itm;
16473 break;
16474 }
16475 }
16476 }
16477 }
16478 break;
16479
16480 case LINKINVIS:
16481 740 Hero.setDontDraw((value ? 2 : 0));
16482 740 break;
16483
16484 case LINKINVINC:
16485 1532 Hero.scriptcoldet=(value/10000);
16486 1532 break;
16487
16488 case LINKENGINEANIMATE:
16489 Hero.do_animation=(value ? 1 : 0);
16490 break;
16491
16492 case LINKSWORDJINX:
16493 4 Hero.setSwordClk(value/10000);
16494 4 break;
16495
16496 case LINKITEMJINX:
16497 5161 Hero.setItemClk(value/10000);
16498 5161 break;
16499
16500 case LINKDRUNK:
16501 Hero.setDrunkClock(value/10000);
16502 break;
16503
16504 case LINKMISCD:
16505 56626 Hero.miscellaneous[vbound(ri->d[rINDEX]/10000,0,31)] = value;
16506 56626 break;
16507
16508 case LINKHITBY:
16509 {
16510 int32_t indx = ri->d[rINDEX]/10000;
16511 switch(indx)
16512 {
16513 //screen index objects
16514 case 0:
16515 case 1:
16516 case 2:
16517 case 3:
16518 case 8:
16519 case 9:
16520 case 10:
16521 case 11:
16522 case 12:
16523 case 16:
16524 {
16525 Hero.sethitHeroUID(indx, (value/10000)); //Why the Flidd did I vbound this? UIDs are LONGs, with a starting value of 0.0001. Why did I allow it, in fact? -Z
16526 break;
16527 }
16528 //UIDs
16529 case 4:
16530 case 5:
16531 case 6:
16532 case 7:
16533 case 13:
16534 case 14:
16535 case 15:
16536 {
16537 Hero.sethitHeroUID(indx, value); //Why the Flidd did I vbound this? UIDs are LONGs, with a starting value of 0.0001. Why did I allow it, in fact? -Z
16538 break;
16539 }
16540 default: { al_trace("Invalid index passed to Player->HitBy[%d] /n", indx); break; }
16541 }
16542 break;
16543 }
16544
16545 case LINKDEFENCE:
16546 Hero.set_defence(vbound(ri->d[rINDEX]/10000,0,255), ((char)vbound((value/10000), 0, 255)));
16547 break;
16548
16549 case LINKHXOFS:
16550 (Hero.hxofs)=(zfix)(value/10000);
16551 break;
16552
16553 case LINKROTATION:
16554 if ( get_qr(qr_OLDSPRITEDRAWS) )
16555 {
16556 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
16557 "Player->Rotation");
16558 break;
16559 }
16560 (Hero.rotation)=(value/10000);
16561 break;
16562
16563 case LINKSCALE:
16564 {
16565 if ( get_qr(qr_OLDSPRITEDRAWS) )
16566 {
16567 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
16568 "Player->Scale");
16569 break;
16570 }
16571 (Hero.scale)=(value/100.0);
16572 //al_trace("Player.scale is: %d\n", Hero.scale);
16573 //al_trace("Trying to set Player.scale to: %d\n", value/100.0);
16574 break;
16575 }
16576
16577 case LINKHYOFS:
16578 (Hero.hyofs)=(zfix)(value/10000);
16579 break;
16580
16581 case LINKXOFS:
16582 (Hero.xofs)=(zfix)(value/10000);
16583 break;
16584
16585 case LINKYOFS:
16586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280560 times.
280560 (Hero.yofs)=(zfix)(value/10000)+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16587 280560 break;
16588 case HEROTOTALDYOFFS:
16589 break; //READ-ONLY
16590
16591 case HEROSHADOWXOFS:
16592 (Hero.shadowxofs)=(zfix)(value/10000);
16593 break;
16594
16595 case HEROSHADOWYOFS:
16596 (Hero.shadowyofs)=(zfix)(value/10000);
16597 break;
16598
16599 case LINKZOFS:
16600 (Hero.zofs)=(zfix)(value/10000);
16601 break;
16602
16603 case LINKHXSZ:
16604 (Hero.hit_width)=(zfix)(value/10000);
16605 break;
16606
16607 case LINKHYSZ:
16608 (Hero.hit_height)=(zfix)(value/10000);
16609 break;
16610
16611 case LINKHZSZ:
16612 (Hero.hzsz)=(zfix)(value/10000);
16613 break;
16614
16615 case LINKTXSZ:
16616 (Hero.txsz)=(zfix)(value/10000);
16617 break;
16618
16619 case LINKTYSZ:
16620 (Hero.tysz)=(zfix)(value/10000);
16621 break;
16622
16623 case LINKTILE:
16624 (Hero.tile)=(zfix)(value/10000);
16625 break;
16626
16627 case LINKFLIP:
16628 (Hero.flip)=(zfix)(value/10000);
16629 break;
16630
16631
16632
16633 case LINKINVFRAME:
16634 Hero.setHClk( (int32_t)vbound((value/10000), 0, 214747) );
16635 break;
16636
16637 case LINKCANFLICKER:
16638 Hero.setCanFlicker((value/10000)?1:0);
16639 break;
16640
16641 case LINKHURTSFX:
16642 Hero.setHurtSFX( (int32_t)vbound((value/10000), 0, 255) );
16643 break;
16644
16645
16646 case LINKITEMB:
16647 {
16648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93759 times.
93759 if ( value/10000 < -1 )
16649 {
16650 al_trace("Tried to write an invalid item ID to Player->ItemB: %d\n",value/10000);
16651 break;
16652 }
16653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93759 times.
93759 if ( value/10000 > MAXITEMS-1 )
16654 {
16655 al_trace("Tried to write an invalid item ID to Player->ItemB: %d\n",value/10000);
16656 break;
16657 }
16658 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
16659
16660
2/2
✓ Branch 0 taken 93750 times.
✓ Branch 1 taken 9 times.
93759 if (Bwpn != (value/10000))
16661 {
16662 9 Bwpn = value/10000;
16663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(new_subscreen_active)
16664 9 new_subscreen_active->get_page_pos(Bwpn, game->bwpn);
16665 9 game->forced_bwpn = value/10000;
16666 9 game->items_off[value/10000] = 0;
16667 9 }
16668 93759 directItemB = value/10000;
16669 93759 break;
16670 }
16671
16672
16673 case LINKITEMA:
16674 {
16675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93760 times.
93760 if ( value/10000 < -1 )
16676 {
16677 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemA: %d\n",value/10000);
16678 break;
16679 }
16680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93760 times.
93760 if ( value/10000 > MAXITEMS-1 )
16681 {
16682 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemA: %d\n",value/10000);
16683 break;
16684 }
16685 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
16686
2/2
✓ Branch 0 taken 93752 times.
✓ Branch 1 taken 8 times.
93760 if (Awpn != (value/10000))
16687 {
16688 8 Awpn = value/10000;
16689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(new_subscreen_active)
16690 8 new_subscreen_active->get_page_pos(Awpn, game->awpn);
16691 8 game->items_off[value/10000] = 0;
16692 8 game->forced_awpn = value/10000;
16693 8 }
16694 93760 directItemA = value/10000;
16695 93760 break;
16696 }
16697
16698 case LINKITEMX:
16699 {
16700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93772 times.
93772 if ( value/10000 < -1 )
16701 {
16702 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemX: %d\n",value/10000);
16703 break;
16704 }
16705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93772 times.
93772 if ( value/10000 > MAXITEMS-1 )
16706 {
16707 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemX: %d\n",value/10000);
16708 break;
16709 }
16710 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
16711
2/2
✓ Branch 0 taken 93739 times.
✓ Branch 1 taken 33 times.
93772 if (Xwpn != (value/10000))
16712 {
16713 33 Xwpn = value/10000;
16714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(new_subscreen_active)
16715 33 new_subscreen_active->get_page_pos(Xwpn, game->xwpn);
16716 33 game->items_off[value/10000] = 0;
16717 33 game->forced_xwpn = value/10000;
16718 33 }
16719 93772 directItemX = value/10000;
16720 93772 break;
16721 }
16722 case LINKITEMY:
16723 {
16724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93778 times.
93778 if ( value/10000 < -1 )
16725 {
16726 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemY: %d\n",value/10000);
16727 break;
16728 }
16729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93778 times.
93778 if ( value/10000 > MAXITEMS-1 )
16730 {
16731 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemY: %d\n",value/10000);
16732 break;
16733 }
16734 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
16735
2/2
✓ Branch 0 taken 93735 times.
✓ Branch 1 taken 43 times.
93778 if (Ywpn != (value/10000))
16736 {
16737 43 Ywpn = value/10000;
16738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(new_subscreen_active)
16739 43 new_subscreen_active->get_page_pos(Ywpn, game->ywpn);
16740 43 game->items_off[value/10000] = 0;
16741 43 game->forced_ywpn = value/10000;
16742 43 }
16743 93778 directItemY = value/10000;
16744 93778 break;
16745 }
16746
16747
16748 case LINKEATEN:
16749 Hero.setEaten(value/10000);
16750 break;
16751 case LINKGRABBED:
16752 Hero.inwallm = value != 0;
16753 break;
16754 case HEROBUNNY:
16755 Hero.setBunnyClock(value/10000);
16756 break;
16757 case LINKPUSH:
16758 Hero.pushing = zc_max((value/10000),0);
16759 break;
16760 case LINKSTUN:
16761 Hero.setStunClock(value/10000);
16762 break;
16763 case LINKSCRIPTTILE:
16764 2569 script_hero_sprite=vbound((value/10000), -1, NEWMAXTILES-1);
16765 2569 break;
16766
16767 case HEROSCRIPTCSET:
16768 script_hero_cset=vbound((value/10000), -1, 0xF);
16769 break;
16770 case LINKSCRIPFLIP:
16771 2569 script_hero_flip=vbound((value/10000),-1,256);
16772 2569 break;
16773
16774 case GAMESETA:
16775 {
16776 //int32_t state = (ri->d[rINDEX2]/10000);
16777 //int32_t extend = (ri->d[rINDEX2]/10000);
16778 //int32_t dir = (ri->d[rINDEX]/10000);
16779 // Z_message("Trying to force-set the A-button item().\n");
16780 // Hero.setAButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
16781 }
16782 break;
16783
16784 case GAMESETB:
16785 {
16786 //int32_t state = (ri->d[rINDEX2]/10000);
16787 //int32_t extend = (ri->d[rINDEX2]/10000);
16788 //int32_t dir = (ri->d[rINDEX]/10000);
16789 // Z_message("Trying to force-set the A-button item().\n");
16790 // Hero.setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
16791 }
16792 break;
16793
16794 //Set Hero Diagonal
16795 case LINKDIAG:
16796 Hero.setDiagMove(value?1:0);
16797 set_qr(qr_LTTPWALK, value?1:0);
16798 break;
16799
16800 //Set Hero Big Hitbox
16801 case LINKBIGHITBOX:
16802 Hero.setBigHitbox((value/10000)?1:0);
16803 set_qr(qr_LTTPCOLLISION, (value/10000)?1:0);
16804 break;
16805
16806 case LINKCLIMBING:
16807 Hero.setOnSideviewLadder(value!=0?true:false);
16808 break;
16809
16810 case HEROJUMPCOUNT:
16811 Hero.extra_jump_count = value/10000;
16812 break;
16813
16814 case HEROPULLCLK:
16815 Hero.pit_pullclk = value/10000;
16816 break;
16817 case HEROFALLCLK:
16818 {
16819 int32_t val = vbound(value/10000,0,70);
16820 if(val)
16821 Hero.setAction(falling);
16822 else if(Hero.action == falling)
16823 {
16824 Hero.setAction(none);
16825 }
16826 Hero.fallclk = val;
16827 break;
16828 }
16829 case HEROFALLCMB:
16830 Hero.fallCombo = vbound(value/10000,0,MAXCOMBOS-1);
16831 break;
16832 case HERODROWNCLK:
16833 {
16834 int32_t val = vbound(value/10000,0,70);
16835 if(val)
16836 {
16837 if (Hero.action != lavadrowning) Hero.setAction(drowning);
16838 }
16839 else if(Hero.action == drowning || Hero.action == lavadrowning)
16840 {
16841 Hero.setAction(none);
16842 }
16843 Hero.drownclk = val;
16844 break;
16845 }
16846 case HERODROWNCMB:
16847 Hero.drownCombo = vbound(value/10000,0,MAXCOMBOS-1);
16848 break;
16849 case HEROFAKEZ:
16850 {
16851 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
16852 {
16853 Hero.setFakeZfix(zslongToFix(value));
16854 }
16855 else
16856 {
16857 Hero.setFakeZ(value/10000);
16858 }
16859 }
16860 break;
16861 case HEROMOVEFLAGS:
16862 {
16863 166 int32_t indx = ri->d[rINDEX]/10000;
16864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
166 if(BC::checkBounds(indx, 0, 10, "Hero->MoveFlags[]") == SH::_NoError)
16865 {
16866 //All bits, in order, of a single byte; just use bitwise
16867 166 int32_t bit = 1<<indx;
16868
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 165 times.
166 if(value)
16869 1 Hero.moveflags |= bit;
16870 else
16871 165 Hero.moveflags &= ~bit;
16872 166 }
16873 166 break;
16874 }
16875 case HEROLIFTFLAGS:
16876 {
16877 int32_t indx = ri->d[rINDEX]/10000;
16878 if(BC::checkBounds(indx, 0, NUM_LIFTFL-1, "Hero->LiftFlags[]") == SH::_NoError)
16879 {
16880 int32_t bit = 1<<indx;
16881 if(value)
16882 Hero.liftflags |= bit;
16883 else
16884 Hero.liftflags &= ~bit;
16885 }
16886 break;
16887 }
16888
16889 case HEROSHIELDJINX:
16890 Hero.shieldjinxclk = value/10000;
16891 break;
16892
16893 case CLOCKACTIVE:
16894 {
16895 Hero.setClock(watch=(value?true:false));
16896 break;
16897 }
16898
16899 case CLOCKCLK:
16900 clockclk = vbound((value/10000), 0, 214748);
16901 break;
16902
16903 case HERORESPAWNX:
16904 {
16905 zfix zx = zslongToFix(value);
16906 Hero.respawn_x = vbound(zx, 0_zf, 240_zf);
16907 break;
16908 }
16909
16910 case HERORESPAWNY:
16911 {
16912 zfix zy = zslongToFix(value);
16913 Hero.respawn_y = vbound(zy, 0_zf, 160_zf);
16914 break;
16915 }
16916
16917 case HERORESPAWNDMAP:
16918 {
16919 Hero.respawn_dmap = vbound(value/10000, 0, MAXDMAPS-1);
16920 break;
16921 }
16922
16923 case HERORESPAWNSCR:
16924 {
16925 Hero.respawn_scr = vbound(value/10000, 0, 0x7F);
16926 break;
16927 }
16928
16929
16930 case HEROSWITCHMAXTIMER:
16931 case HEROSWITCHTIMER:
16932 break; //read-only
16933
16934 case HEROIMMORTAL:
16935 {
16936 Hero.setImmortal(value/10000);
16937 break;
16938 }
16939
16940 case HEROCOYOTETIME:
16941 {
16942 auto v = value/10000;
16943 if(v < 0 || v > 65535) v = 65535;
16944 Hero.coyotetime = word(v);
16945 break;
16946 }
16947 case HEROLIFTEDWPN:
16948 {
16949 if(Hero.lift_wpn)
16950 {
16951 delete Hero.lift_wpn;
16952 Hero.lift_wpn = nullptr;
16953 }
16954 if(value)
16955 {
16956 if(weapon* wpn = checkLWpn(value,"Hero->LiftedWeapon"))
16957 {
16958 if(wpn == Hero.lift_wpn) break;
16959 Hero.lift_wpn = wpn;
16960 if(Lwpns.find(wpn) > -1)
16961 Lwpns.remove(wpn);
16962 if(curScriptType == ScriptType::Lwpn && value == curScriptIndex)
16963 earlyretval = RUNSCRIPT_SELFREMOVE;
16964 }
16965 }
16966 break;
16967 }
16968 case HEROLIFTTIMER:
16969 {
16970 Hero.liftclk = value/10000;
16971 break;
16972 }
16973 case HEROLIFTMAXTIMER:
16974 {
16975 Hero.tliftclk = value/10000;
16976 break;
16977 }
16978 case HEROLIFTHEIGHT:
16979 {
16980 Hero.liftheight = zslongToFix(value);
16981 break;
16982 }
16983 case HEROHAMMERSTATE:
16984 {
16985 //readonly
16986 break;
16987 }
16988
16989
16990 ///----------------------------------------------------------------------------------------------------//
16991 //Input States
16992 case INPUTSTART:
16993 {
16994 928305 control_state[6]=(value?true:false);
16995
2/2
✓ Branch 0 taken 928224 times.
✓ Branch 1 taken 81 times.
928305 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[6]=false;
16996 928305 break;
16997 }
16998
16999 case INPUTMAP:
17000 {
17001 461908 control_state[9]=(value?true:false);
17002
2/2
✓ Branch 0 taken 461809 times.
✓ Branch 1 taken 99 times.
461908 if ( get_qr(qr_FIXDRUNKINPUTS) )
17003 99 drunk_toggle_state[9]=false;
17004 461908 break;
17005 }
17006
17007 case INPUTUP:
17008 {
17009 249228 control_state[0]=(value?true:false);
17010
2/2
✓ Branch 0 taken 248029 times.
✓ Branch 1 taken 1199 times.
249228 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[0]=false;
17011 249228 break;
17012 }
17013
17014 case INPUTDOWN:
17015 {
17016 249220 control_state[1]=(value?true:false);
17017
2/2
✓ Branch 0 taken 248027 times.
✓ Branch 1 taken 1193 times.
249220 if ( get_qr(qr_FIXDRUNKINPUTS) )
17018 1193 drunk_toggle_state[1]=false;
17019 249220 break;
17020 }
17021
17022 case INPUTLEFT:
17023 {
17024 236658 control_state[2]=(value?true:false);
17025
2/2
✓ Branch 0 taken 235481 times.
✓ Branch 1 taken 1177 times.
236658 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[2]=false;
17026 236658 break;
17027 }
17028
17029 case INPUTRIGHT:
17030 {
17031 236880 control_state[3]=(value?true:false);
17032
2/2
✓ Branch 0 taken 235703 times.
✓ Branch 1 taken 1177 times.
236880 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[3]=false;
17033 236880 break;
17034 }
17035
17036 case INPUTA:
17037 {
17038 89166 control_state[4]=(value?true:false);
17039
2/2
✓ Branch 0 taken 89113 times.
✓ Branch 1 taken 53 times.
89166 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[4]=false;
17040 89166 break;
17041 }
17042
17043 case INPUTB:
17044 {
17045 76223 control_state[5]=(value?true:false);
17046
1/2
✓ Branch 0 taken 76223 times.
✗ Branch 1 not taken.
76223 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[5]=false;
17047 76223 break;
17048 }
17049
17050 case INPUTL:
17051 {
17052 78737 control_state[7]=(value?true:false);
17053
2/2
✓ Branch 0 taken 78656 times.
✓ Branch 1 taken 81 times.
78737 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[7]=false;
17054 78737 break;
17055 }
17056
17057 case INPUTR:
17058 {
17059 78784 control_state[8]=(value?true:false);
17060
2/2
✓ Branch 0 taken 78703 times.
✓ Branch 1 taken 81 times.
78784 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[8]=false;
17061 78784 break;
17062 }
17063
17064 case INPUTEX1:
17065 {
17066 222649 control_state[10]=(value?true:false);
17067 222649 break;
17068 }
17069
17070 case INPUTEX2:
17071 222649 control_state[11]=(value?true:false);
17072 222649 break;
17073
17074 case INPUTEX3:
17075 222649 control_state[12]=(value?true:false);
17076 222649 break;
17077
17078 case INPUTEX4:
17079 222649 control_state[13]=(value?true:false);
17080 222649 break;
17081
17082 case INPUTAXISUP:
17083 control_state[14]=(value?true:false);
17084 break;
17085
17086 case INPUTAXISDOWN:
17087 control_state[15]=(value?true:false);
17088 break;
17089
17090 case INPUTAXISLEFT:
17091 control_state[16]=(value?true:false);
17092 break;
17093
17094 case INPUTAXISRIGHT:
17095 control_state[17]=(value?true:false);
17096 break;
17097
17098 case INPUTPRESSSTART:
17099 928305 button_press[6]=(value?true:false);
17100 928305 break;
17101
17102 case INPUTPRESSMAP:
17103 461908 button_press[9]=(value?true:false);
17104 461908 break;
17105
17106 case INPUTPRESSUP:
17107 218369 button_press[0]=(value?true:false);
17108 218369 break;
17109
17110 case INPUTPRESSDOWN:
17111 218364 button_press[1]=(value?true:false);
17112 218364 break;
17113
17114 case INPUTPRESSLEFT:
17115 218431 button_press[2]=(value?true:false);
17116 218431 break;
17117
17118 case INPUTPRESSRIGHT:
17119 218461 button_press[3]=(value?true:false);
17120 218461 break;
17121
17122 case INPUTPRESSA:
17123 83086 button_press[4]=(value?true:false);
17124 83086 break;
17125
17126 case INPUTPRESSB:
17127 70141 button_press[5]=(value?true:false);
17128 70141 break;
17129
17130 case INPUTPRESSL:
17131 75869 button_press[7]=(value?true:false);
17132 75869 break;
17133
17134 case INPUTPRESSR:
17135 75916 button_press[8]=(value?true:false);
17136 75916 break;
17137
17138 case INPUTPRESSEX1:
17139 222649 button_press[10]=(value?true:false);
17140 222649 break;
17141
17142 case INPUTPRESSEX2:
17143 222649 button_press[11]=(value?true:false);
17144 222649 break;
17145
17146 case INPUTPRESSEX3:
17147 222649 button_press[12]=(value?true:false);
17148 222649 break;
17149
17150 case INPUTPRESSEX4:
17151 222649 button_press[13]=(value?true:false);
17152 222649 break;
17153
17154 case INPUTPRESSAXISUP:
17155 button_press[14]=(value?true:false);
17156 break;
17157
17158 case INPUTPRESSAXISDOWN:
17159 button_press[15]=(value?true:false);
17160 break;
17161
17162 case INPUTPRESSAXISLEFT:
17163 button_press[16]=(value?true:false);
17164 break;
17165
17166 case INPUTPRESSAXISRIGHT:
17167 button_press[17]=(value?true:false);
17168 break;
17169
17170 case INPUTMOUSEX:
17171 {
17172 auto [x, y] = rti_game.local_to_world(value/10000, mouse_y);
17173 position_mouse(x, y);
17174 break;
17175 }
17176
17177 case INPUTMOUSEY:
17178 {
17179 int32_t mousequakeoffset = 56+((int32_t)(zc::math::Sin((double)(quakeclk*int64_t(2)-frame))*4));
17180 int32_t tempoffset = (quakeclk > 0) ? mousequakeoffset : (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17181 auto [x, y] = rti_game.local_to_world(mouse_x, value/10000 + tempoffset);
17182 position_mouse(x, y);
17183 break;
17184 }
17185
17186 case INPUTMOUSEZ:
17187 position_mouse_z(value/10000);
17188 break;
17189
17190 case FFRULE:
17191 {
17192 int32_t ruleid = vbound((ri->d[rINDEX]/10000),0,qr_MAX);
17193 set_qr(ruleid, (value?true:false));
17194 switch(ruleid)
17195 {
17196 case qr_LTTPWALK:
17197 Hero.setDiagMove(value?1:0);
17198 break;
17199 case qr_LTTPCOLLISION:
17200 Hero.setBigHitbox(value?1:0);
17201 break;
17202 case qr_ZS_NO_NEG_ARRAY:
17203 can_neg_array = !value;
17204 break;
17205 }
17206 }
17207 break;
17208
17209 case BUTTONPRESS:
17210 // DUkey, DDkey, DLkey, DRkey, Akey, Bkey, Skey, Lkey, Rkey, Pkey, Exkey1, Exkey2, Exkey3, Exkey4 };
17211 {
17212 //Read-only
17213 281179 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
17214 281179 button_press[button]=(value?true:false);
17215
4/4
✓ Branch 0 taken 220927 times.
✓ Branch 1 taken 60252 times.
✓ Branch 2 taken 42471 times.
✓ Branch 3 taken 178456 times.
281179 if ( button < 11 && get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[button]=false;
17216
17217 }
17218 281179 break;
17219
17220 case BUTTONINPUT:
17221 {
17222 //Read-only
17223 281265 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
17224 281265 control_state[button]=(value?true:false);
17225
4/4
✓ Branch 0 taken 221013 times.
✓ Branch 1 taken 60252 times.
✓ Branch 2 taken 42557 times.
✓ Branch 3 taken 178456 times.
281265 if ( button < 11 && get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[button]=false;
17226 }
17227 281265 break;
17228
17229 case BUTTONHELD:
17230 {
17231 //Read-only
17232 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
17233 button_hold[button]=(value?true:false);
17234 }
17235 break;
17236
17237 case RAWKEY:
17238 { //Game->KeyPressed[], read-only
17239 //if ( !keypressed() ) break; //Don;t return values set by setting Hero->Input/Press
17240 //hmm...no, this won;t return properly for modifier keys.
17241 int32_t keyid = ri->d[rINDEX]/10000;
17242 //key = vbound(key,0,n);
17243 _key[keyid]=key[keyid]=key_current_frame[keyid]=(value?true:false); //It isn't possible to set keys true, because polling occurs before they are set?
17244 //but they *can* be set false; ??? -Z
17245 }
17246 break;
17247
17248 case KEYINPUT:
17249 {
17250 KeyInput[ri->d[rINDEX]/10000] = (value/10000)!=0;
17251 switch(ri->d[rINDEX]/10000)
17252 {
17253 case KEY_F6: onTryQuit(); break;
17254 case KEY_F3: Paused = !Paused; break;
17255 case KEY_F4: Paused = true; Advance = true; break;
17256 }
17257 break;
17258 }
17259 case KEYPRESS:
17260 {
17261 KeyPress[ri->d[rINDEX]/10000] = (value/10000)!=0;
17262 break;
17263 }
17264
17265 case SIMULATEKEYPRESS:
17266 { //Game->KeyPressed[], read-only
17267 //if ( !keypressed() ) break; //Don;t return values set by setting Hero->Input/Press
17268 //hmm...no, this won;t return properly for modifier keys.
17269 int32_t keyid = ri->d[rINDEX]/10000;
17270 //key = vbound(key,0,n);
17271 if (value/10000) simulate_keypress(keyid << 8);
17272 }
17273 break;
17274
17275 case KEYMODIFIERS:
17276 {
17277 key_shifts = ( value/10000 );
17278 break;
17279 }
17280
17281 case KEYBINDINGS:
17282 {
17283 int32_t keyid = ri->d[rINDEX]/10000;
17284 switch(keyid)
17285 {
17286 case 0: DUkey = ( value/10000 ); break;
17287 case 1: DDkey = ( value/10000 ); break;
17288 case 2: DLkey = ( value/10000 ); break;
17289 case 3: DRkey = ( value/10000 ); break;
17290 case 4: Akey = ( value/10000 ); break;
17291 case 5: Bkey = ( value/10000 ); break;
17292 case 6: Skey = ( value/10000 ); break;
17293 case 7: Lkey = ( value/10000 ); break;
17294 case 8: Rkey = ( value/10000 ); break;
17295 case 9: Pkey = ( value/10000 ); /*map*/ break;
17296 case 10: Exkey1 = ( value/10000 ); break;
17297 case 11: Exkey2 = ( value/10000 ); break;
17298 case 12: Exkey3 = ( value/10000 ); break;
17299 case 13: Exkey4 = ( value/10000 ); break;
17300
17301 default: { Z_scripterrlog("Invalid index [%d] passed to Input->KeyBindings[]\n", keyid); break; }
17302 }
17303 break;
17304 }
17305
17306 case DISABLEKEY:
17307 {
17308 //Input->DisableKey(int32_t key, bool disable)
17309 int32_t keyid = ri->d[rINDEX]/10000;
17310 if(!zc_disablekey(keyid, value))
17311 {
17312 //Z_scripterrlog("The key %d passed to Input->DisableKey[] is system-reserved, and cannot be disabled\n",keyid);
17313 }
17314 break;
17315 }
17316
17317 case DISABLEBUTTON:
17318 {
17319 //Input->DisableButton(int32_t cb, bool disable)
17320 int32_t cbid = ri->d[rINDEX]/10000;
17321 disable_control[cbid] = value?true:false;
17322 break;
17323 }
17324
17325 case MOUSEARR:
17326 {
17327 int32_t indx = (ri->d[rINDEX]/10000);
17328 switch (indx)
17329 {
17330 case 0: //MouseX
17331 {
17332 auto [x, y] = rti_game.local_to_world(value/10000, mouse_y);
17333 position_mouse(x, y);
17334 break;
17335 }
17336 case 1: //MouseY
17337 {
17338 int32_t mousequakeoffset = 56+((int32_t)(zc::math::Sin((double)(quakeclk*int64_t(2)-frame))*4));
17339 int32_t tempoffset = (quakeclk > 0) ? mousequakeoffset :(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17340 auto [x, y] = rti_game.local_to_world(mouse_x, value/10000 + tempoffset);
17341 position_mouse(x, y);
17342 break;
17343
17344 }
17345 case 2: //MouseZ
17346 {
17347 position_mouse_z(value/10000);
17348 break;
17349 }
17350 case 3: //Left Click
17351 {
17352 if ( value ) mouse_b |= 1;
17353 else mouse_b &= ~1;
17354 break;
17355 }
17356 case 4: //Right Click
17357 {
17358 if ( value ) mouse_b |= 2;
17359 else mouse_b &= ~2;
17360 break;
17361 }
17362 case 5: //Middle Click
17363 {
17364 if ( value ) mouse_b |= 4;
17365 else mouse_b &= ~4;
17366 break;
17367 }
17368 default:
17369 {
17370 Z_scripterrlog("Invalid index passed to Input->Mouse[]: %d\n", indx);
17371 }
17372 }
17373
17374 }
17375 break;
17376
17377
17378 ///----------------------------------------------------------------------------------------------------//
17379 //Item Variables
17380
17381 case ITEMFAMILY:
17382 if(0!=(s=checkItem(ri->itemref)))
17383 {
17384 (((item *)s)->family)=value/10000;
17385 }
17386
17387 break;
17388
17389 case ITEMLEVEL:
17390 if(0!=(s=checkItem(ri->itemref)))
17391 {
17392 (((item *)s)->lvl)=value/10000;
17393 }
17394
17395 break;
17396
17397 case SPRITEMAXITEM:
17398 {
17399 //No bounds check, as this is a universal function and works from NULL pointers!
17400 items.setMax(vbound((value/10000),1,MAX_ITEM_SPRITES));
17401 break;
17402 }
17403
17404 case ITEMX:
17405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21848 times.
21848 if(0!=(s=checkItem(ri->itemref)))
17406 {
17407
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 21678 times.
21848 (s->x)=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
17408
17409 // Move the Fairy enemy as well.
17410
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 21838 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
21848 if(itemsbuf[((item*)(s))->id].family==itype_fairy && itemsbuf[((item*)(s))->id].misc3)
17411 movefairynew2(((item*)(s))->x,((item*)(s))->y,*((item*)(s)));
17412 21848 }
17413
17414 21848 break;
17415
17416 case ITEMSPRITESCRIPT:
17417 31 FFScript::deallocateAllScriptOwned(ScriptType::ItemSprite, ri->itemref);
17418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(0!=(s=checkItem(ri->itemref)))
17419 {
17420 31 (s->script)=(value/10000);
17421 31 }
17422 31 break;
17423
17424 case ITEMSCALE:
17425 if ( get_qr(qr_OLDSPRITEDRAWS) )
17426 {
17427 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
17428 "item->Scale");
17429 break;
17430 }
17431 if(0!=(s=checkItem(ri->itemref)))
17432 {
17433 (s->scale)=(zfix)(value/100.0);
17434 }
17435
17436 break;
17437
17438 case ITEMY:
17439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41791 times.
41791 if(0!=(s=checkItem(ri->itemref)))
17440 {
17441
2/2
✓ Branch 0 taken 1142 times.
✓ Branch 1 taken 40649 times.
41791 (s->y)=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
17442
17443 // Move the Fairy enemy as well.
17444
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 41781 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
41791 if(itemsbuf[((item*)(s))->id].family==itype_fairy && itemsbuf[((item*)(s))->id].misc3)
17445 movefairynew2(((item*)(s))->x,((item*)(s))->y,*((item*)(s)));
17446 41791 }
17447
17448 41791 break;
17449
17450 case ITEMZ:
17451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(0!=(s=checkItem(ri->itemref)))
17452 {
17453 92 (s->z)=(zfix)(value/10000);
17454
17455
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(s->z < 0)
17456 s->z = 0;
17457 92 }
17458
17459 92 break;
17460
17461 case ITEMJUMP:
17462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49959 times.
49959 if(0!=(s=checkItem(ri->itemref)))
17463 {
17464 49959 (((item *)s)->fall)=zslongToFix(value)*-100;
17465 49959 }
17466
17467 49959 break;
17468
17469 case ITEMFAKEJUMP:
17470 if(0!=(s=checkItem(ri->itemref)))
17471 {
17472 (((item *)s)->fakefall)=zslongToFix(value)*-100;
17473 }
17474
17475 break;
17476
17477 case ITEMDRAWTYPE:
17478 if(0!=(s=checkItem(ri->itemref)))
17479 {
17480 (((item *)s)->drawstyle)=value/10000;
17481 }
17482
17483 break;
17484
17485 case ITEMSPRITEINITD:
17486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(0!=(s=checkItem(ri->itemref)))
17487 {
17488 37 int32_t a = vbound(ri->d[rINDEX]/10000,0,7);
17489 37 (((item *)s)->initD[a])=value;
17490 37 }
17491
17492 37 break;
17493
17494 case ITEMGRAVITY:
17495 if(0!=(s=checkItem(ri->itemref)))
17496 {
17497 if(value)
17498 ((item *)s)->moveflags |= FLAG_OBEYS_GRAV;
17499 else
17500 ((item *)s)->moveflags &= ~FLAG_OBEYS_GRAV;
17501 }
17502
17503 break;
17504
17505 case ITEMID:
17506 if(0!=(s=checkItem(ri->itemref)))
17507 {
17508 (((item *)s)->id)=value/10000;
17509 flushItemCache();
17510 }
17511
17512 break;
17513
17514 case ITEMTILE:
17515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(0!=(s=checkItem(ri->itemref)))
17516 {
17517 109 (((item *)s)->tile)=vbound(value/10000,0,NEWMAXTILES-1);
17518 109 }
17519
17520 109 break;
17521
17522 case ITEMSCRIPTTILE:
17523 if(0!=(s=checkItem(ri->itemref)))
17524 {
17525 (((item *)s)->scripttile)=vbound(value/10000,-1,NEWMAXTILES-1);
17526 }
17527 break;
17528
17529 case ITEMSCRIPTFLIP:
17530 if(0!=(s=checkItem(ri->itemref)))
17531 {
17532 (((item *)s)->scriptflip)=vbound((value/10000),-1,127);
17533 }
17534 break;
17535
17536 case ITEMPSTRING:
17537 if(0!=(s=checkItem(ri->itemref)))
17538 {
17539 (((item *)s)->pstring)=vbound(value/10000,0,(msg_count-1));
17540 }
17541
17542 break;
17543
17544 case ITEMPSTRINGFLAGS:
17545 if(0!=(s=checkItem(ri->itemref)))
17546 {
17547 (((item *)s)->pickup_string_flags)=vbound(value/10000, 0, 214748);
17548 }
17549
17550 break;
17551
17552 case ITEMOVERRIDEFLAGS:
17553 break;
17554
17555 case ITEMOTILE:
17556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(0!=(s=checkItem(ri->itemref)))
17557 {
17558 40 (((item *)s)->o_tile)=vbound(value/10000,0,NEWMAXTILES-1);
17559 40 }
17560
17561 40 break;
17562
17563 case ITEMCSET:
17564 if(0!=(s=checkItem(ri->itemref)))
17565 {
17566 (((item *)s)->o_cset) = (((item *)s)->o_cset & ~15) | ((value/10000)&15);
17567 (((item *)s)->cs) = (((item *)s)->o_cset & 15);
17568 }
17569
17570 break;
17571
17572 case ITEMFLASHCSET:
17573 if(0!=(s=checkItem(ri->itemref)))
17574 {
17575 (((item *)s)->o_cset) = ((value/10000)<<4) | (((item *)s)->o_cset & 15);
17576 }
17577
17578 break;
17579
17580 case ITEMFRAMES:
17581 if(0!=(s=checkItem(ri->itemref)))
17582 {
17583 (((item *)s)->frames)=value/10000;
17584 }
17585
17586 break;
17587
17588 case ITEMFRAME:
17589 if(0!=(s=checkItem(ri->itemref)))
17590 {
17591 (((item *)s)->aframe)=value/10000;
17592 }
17593
17594 break;
17595
17596 case ITEMASPEED:
17597 if(0!=(s=checkItem(ri->itemref)))
17598 {
17599 (((item *)s)->o_speed)=value/10000;
17600 }
17601
17602 break;
17603
17604 case ITEMACLK:
17605 if(0!=(s=checkItem(ri->itemref)))
17606 {
17607 (((item *)s)->aclk)=value/10000;
17608 }
17609
17610 break;
17611
17612 case ITEMDELAY:
17613 if(0!=(s=checkItem(ri->itemref)))
17614 {
17615 (((item *)s)->o_delay)=value/10000;
17616 }
17617
17618 break;
17619
17620 case ITEMFLIP:
17621 if(0!=(s=checkItem(ri->itemref)))
17622 {
17623 (((item *)s)->flip)=value/10000;
17624 }
17625
17626 break;
17627
17628 case ITEMFLASH:
17629 if(0!=(s=checkItem(ri->itemref)))
17630 {
17631 (((item *)s)->flash)= (value/10000)?1:0;
17632 }
17633
17634 break;
17635
17636 case ITEMEXTEND:
17637 if(0!=(s=checkItem(ri->itemref)))
17638 {
17639 (((item *)s)->extend)=value/10000;
17640 }
17641
17642 break;
17643
17644 case ITEMHXOFS:
17645 if(0!=(s=checkItem(ri->itemref)))
17646 {
17647 ((item*)(s))->hxofs=value/10000;
17648 }
17649
17650 break;
17651
17652 case ITEMROTATION:
17653 if ( get_qr(qr_OLDSPRITEDRAWS) )
17654 {
17655 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
17656 "item->Rotation");
17657 break;
17658 }
17659 if(0!=(s=checkItem(ri->itemref)))
17660 {
17661 ((item*)(s))->rotation=value/10000;
17662 }
17663
17664 break;
17665
17666 case ITEMHYOFS:
17667 if(0!=(s=checkItem(ri->itemref)))
17668 {
17669 ((item*)(s))->hyofs=value/10000;
17670 }
17671
17672 break;
17673
17674 case ITEMXOFS:
17675 if(0!=(s=checkItem(ri->itemref)))
17676 {
17677 ((item*)(s))->xofs=(zfix)(value/10000);
17678 }
17679
17680 break;
17681
17682 case ITEMYOFS:
17683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(0!=(s=checkItem(ri->itemref)))
17684 {
17685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 ((item*)(s))->yofs=(zfix)(value/10000)+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17686 6 }
17687
17688 6 break;
17689
17690 case ITEMSHADOWXOFS:
17691 if(0!=(s=checkItem(ri->itemref)))
17692 {
17693 ((item*)(s))->shadowxofs=(zfix)(value/10000);
17694 }
17695
17696 break;
17697
17698 case ITEMSHADOWYOFS:
17699 if(0!=(s=checkItem(ri->itemref)))
17700 {
17701 ((item*)(s))->shadowyofs=(zfix)(value/10000);
17702 }
17703
17704 break;
17705
17706 case ITEMZOFS:
17707 if(0!=(s=checkItem(ri->itemref)))
17708 {
17709 ((item*)(s))->zofs=(zfix)(value/10000);
17710 }
17711
17712 break;
17713
17714 case ITEMHXSZ:
17715 if(0!=(s=checkItem(ri->itemref)))
17716 {
17717 ((item*)(s))->hit_width=value/10000;
17718 }
17719
17720 break;
17721
17722 case ITEMHYSZ:
17723 if(0!=(s=checkItem(ri->itemref)))
17724 {
17725 ((item*)(s))->hit_height=value/10000;
17726 }
17727
17728 break;
17729
17730 case ITEMHZSZ:
17731 if(0!=(s=checkItem(ri->itemref)))
17732 {
17733 ((item*)(s))->hzsz=value/10000;
17734 }
17735
17736 break;
17737
17738 case ITEMTXSZ:
17739 if(0!=(s=checkItem(ri->itemref)))
17740 {
17741 ((item*)(s))->txsz=vbound((value/10000),1,20);
17742 }
17743
17744 break;
17745
17746 case ITEMTYSZ:
17747 if(0!=(s=checkItem(ri->itemref)))
17748 {
17749 ((item*)(s))->tysz=vbound((value/10000),1,20);
17750 }
17751
17752 break;
17753
17754 case ITEMPICKUP:
17755
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 1181 times.
787 if(0!=(s=checkItem(ri->itemref)))
17756 {
17757 1181 int32_t newpickup = value/10000;
17758 // Values that the questmaker should not use, ever
17759 //Allowing it, for now, until something breaks. -Z 21-Jan-2020
17760 //newpickup &= ~(ipBIGRANGE | ipCHECK | ipMONEY | ipBIGTRI | ipNODRAW | ipFADE);
17761 //
17762
4/4
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 461 times.
✓ Branch 2 taken 197 times.
✓ Branch 3 taken 264 times.
1181 if (( FFCore.GetQuestVersion() == 0x250 && FFCore.GetQuestBuild() < 33 ) //this ishowit looks in 2.53.1, Beta 25
17763 1181 || ( FFCore.GetQuestVersion() < 0x250 ))
17764 {
17765 917 newpickup &= ~(ipBIGRANGE | ipCHECK | ipMONEY | ipBIGTRI | ipNODRAW | ipFADE);
17766 917 }
17767
17768 // If making an item timeout, set its timer
17769
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 70 times.
787 if(newpickup & ipFADE)
17770 {
17771 70 (((item*)(s))->clk2) = 512;
17772 70 }
17773 //else if(newpickup & ~ipFADE)
17774 //{
17775 // (((item*)(s))->clk2) = 0;
17776 //}
17777
17778 // If making it a carried item,
17779 // alter hasitem and set an itemguy.
17780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
787 if((((item*)(s))->pickup & ipENEMY) < (newpickup & ipENEMY))
17781 {
17782 hasitem |= 2;
17783 bool hasitemguy = false;
17784
17785 for(int32_t i=0; i<guys.Count(); i++)
17786 {
17787 if(((enemy*)guys.spr(i))->itemguy)
17788 {
17789 hasitemguy = true;
17790 }
17791 }
17792
17793 if(!hasitemguy && guys.Count()>0)
17794 {
17795 ((enemy*)guys.spr(guys.Count()-1))->itemguy = true;
17796 }
17797 }
17798 // If unmaking it a carried item,
17799 // alter hasitem if there are no more carried items.
17800
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 else if((((item*)(s))->pickup & ipENEMY) > (newpickup & ipENEMY))
17801 {
17802 // Move it back onscreen!
17803 if(get_qr(qr_HIDECARRIEDITEMS))
17804 {
17805 for(int32_t i=0; i<guys.Count(); i++)
17806 {
17807 if(((enemy*)guys.spr(i))->itemguy)
17808 {
17809 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
17810 {
17811 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
17812 {
17813 ((item*)(s))->x = ((enemy*)guys.spr(i))->x+((enemy*)guys.spr(i))->hxofs+(((enemy*)guys.spr(i))->hit_width/2)-8;
17814 ((item*)(s))->y = ((enemy*)guys.spr(i))->y+((enemy*)guys.spr(i))->hyofs+(((enemy*)guys.spr(i))->hit_height/2)-10;
17815 ((item*)(s))->z = ((enemy*)guys.spr(i))->z;
17816 }
17817 else
17818 {
17819 if(((enemy*)guys.spr(i))->extend >= 3)
17820 {
17821 ((item*)(s))->x = ((enemy*)guys.spr(i))->x+(((enemy*)guys.spr(i))->txsz-1)*8;
17822 ((item*)(s))->y = ((enemy*)guys.spr(i))->y-2+(((enemy*)guys.spr(i))->tysz-1)*8;
17823 ((item*)(s))->z = ((enemy*)guys.spr(i))->z;
17824 }
17825 else
17826 {
17827 ((item*)(s))->x = ((enemy*)guys.spr(i))->x;
17828 ((item*)(s))->y = ((enemy*)guys.spr(i))->y - 2;
17829 ((item*)(s))->z = ((enemy*)guys.spr(i))->z;
17830 }
17831 }
17832 }
17833 else
17834 {
17835 ((item*)(s))->x = ((enemy*)guys.spr(i))->x;
17836 ((item*)(s))->y = ((enemy*)guys.spr(i))->y - 2;
17837 ((item*)(s))->z = ((enemy*)guys.spr(i))->z;
17838 }
17839 break;
17840 }
17841 }
17842 }
17843
17844 if(more_carried_items()<=1) // 1 includes this own item.
17845 {
17846 hasitem &= ~2;
17847 }
17848 }
17849
17850 787 ((item*)(s))->pickup=value/10000;
17851 787 }
17852
17853 1181 break;
17854
17855 case ITEMMISCD:
17856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3013 times.
3013 if(0!=(s=checkItem(ri->itemref)))
17857 {
17858 3013 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
17859 3013 (((item*)(s))->miscellaneous[a])=value;
17860 3013 }
17861
17862 3013 break;
17863 case ITEMFALLCLK:
17864 if(0!=(s=checkItem(ri->itemref)))
17865 {
17866 if(((item*)(s))->fallclk != 0 && value == 0)
17867 {
17868 ((item*)(s))->cs = ((item*)(s))->old_cset;
17869 ((item*)(s))->tile = ((item*)(s))->o_tile;
17870 }
17871 else if(((item*)(s))->fallclk == 0 && value != 0) ((item*)(s))->old_cset = ((item*)(s))->cs;
17872 ((item*)(s))->fallclk = vbound(value/10000,0,70);
17873 }
17874 break;
17875 case ITEMFALLCMB:
17876 if(0!=(s=checkItem(ri->itemref)))
17877 {
17878 ((item*)(s))->fallCombo = vbound(value/10000,0,MAXCOMBOS-1);
17879 }
17880 break;
17881 case ITEMDROWNCLK:
17882 if(0!=(s=checkItem(ri->itemref)))
17883 {
17884 if(((item*)(s))->drownclk != 0 && value == 0)
17885 {
17886 ((item*)(s))->cs = ((item*)(s))->old_cset;
17887 ((item*)(s))->tile = ((item*)(s))->o_tile;
17888 }
17889 else if(((item*)(s))->drownclk == 0 && value != 0) ((item*)(s))->old_cset = ((item*)(s))->cs;
17890 ((item*)(s))->drownclk = vbound(value/10000,0,70);
17891 }
17892 break;
17893 case ITEMDROWNCMB:
17894 if(0!=(s=checkItem(ri->itemref)))
17895 {
17896 ((item*)(s))->drownCombo = vbound(value/10000,0,MAXCOMBOS-1);
17897 }
17898 break;
17899 case ITEMFAKEZ:
17900 if(0!=(s=checkItem(ri->itemref)))
17901 {
17902 (s->fakez)=(zfix)(value/10000);
17903
17904 if(s->fakez < 0)
17905 s->fakez = 0;
17906 }
17907
17908 break;
17909
17910 case ITEMMOVEFLAGS:
17911 {
17912
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 if(0!=(s=checkItem(ri->itemref)))
17913 {
17914 68 int32_t indx = ri->d[rINDEX]/10000;
17915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(BC::checkBounds(indx, 0, 10, "itemsprite->MoveFlags[]") == SH::_NoError)
17916 {
17917 //All bits, in order, of a single byte; just use bitwise
17918 68 int32_t bit = 1<<indx;
17919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(value)
17920 ((item*)(s))->moveflags |= bit;
17921 else
17922 68 ((item*)(s))->moveflags &= ~bit;
17923 68 }
17924 68 }
17925 68 break;
17926 }
17927
17928 case ITEMGLOWRAD:
17929 if(0!=(s=checkItem(ri->itemref)))
17930 {
17931 ((item*)(s))->glowRad = vbound(value/10000,0,255);
17932 }
17933 break;
17934
17935 case ITEMGLOWSHP:
17936 if(0!=(s=checkItem(ri->itemref)))
17937 {
17938 ((item*)(s))->glowShape = vbound(value/10000,0,255);
17939 }
17940 break;
17941
17942 case ITEMDIR:
17943 if(0!=(s=checkItem(ri->itemref)))
17944 {
17945 ((item*)(s))->dir=(value/10000);
17946 }
17947 break;
17948
17949 case ITEMENGINEANIMATE:
17950 if(0!=(s=checkItem(ri->itemref)))
17951 {
17952 ((item*)(s))->do_animation=(value ? 1 : 0);
17953 }
17954 break;
17955
17956 case ITEMSHADOWSPR:
17957 if(0!=(s=checkItem(ri->itemref)))
17958 {
17959 ((item*)(s))->spr_shadow=vbound(value/10000,0,255);
17960 }
17961 break;
17962 case ITEMDROPPEDBY:
17963 if(0!=(s=checkItem(ri->itemref)))
17964 {
17965 ((item*)(s))->from_dropset=vbound(value/10000,-1,255);
17966 }
17967 break;
17968 case ITMSWHOOKED:
17969 break; //read-only
17970 case ITEMFORCEGRAB:
17971 if(0!=(s=checkItem(ri->itemref)))
17972 {
17973 ((item*)(s))->set_forcegrab(value!=0);
17974 }
17975 break;
17976
17977 ///----------------------------------------------------------------------------------------------------//
17978 //Itemdata Variables
17979 //not mine, but let;s guard some of them all the same -Z
17980 //item class
17981 case IDATAFAMILY:
17982 if(unsigned(ri->idata) >= MAXITEMS)
17983 {
17984 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
17985 break;
17986 }
17987 (itemsbuf[ri->idata].family)=vbound(value/10000,0, 254);
17988 flushItemCache();
17989 break;
17990
17991 case IDATAUSEWPN:
17992 if(unsigned(ri->idata) >= MAXITEMS)
17993 {
17994 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
17995 break;
17996 }
17997 (itemsbuf[ri->idata].useweapon)=vbound(value/10000, 0, 255);
17998 break;
17999 case IDATAUSEDEF:
18000 if(unsigned(ri->idata) >= MAXITEMS)
18001 {
18002 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18003 break;
18004 }
18005 (itemsbuf[ri->idata].usedefence)=vbound(value/10000, 0, 255);
18006 break;
18007 case IDATAWRANGE:
18008 if(unsigned(ri->idata) >= MAXITEMS)
18009 {
18010 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18011 break;
18012 }
18013 (itemsbuf[ri->idata].weaprange)=vbound(value/10000, 0, 255);
18014 break;
18015 case IDATAMAGICTIMER:
18016 if(unsigned(ri->idata) >= MAXITEMS)
18017 {
18018 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18019 break;
18020 }
18021 (itemsbuf[ri->idata].magiccosttimer[0])=vbound(value/10000, 0, 214747);
18022 break;
18023 case IDATAMAGICTIMER2:
18024 if(unsigned(ri->idata) >= MAXITEMS)
18025 {
18026 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18027 break;
18028 }
18029 (itemsbuf[ri->idata].magiccosttimer[1])=vbound(value/10000, 0, 214747);
18030 break;
18031 case IDATADURATION:
18032 if(unsigned(ri->idata) >= MAXITEMS)
18033 {
18034 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18035 break;
18036 }
18037 (itemsbuf[ri->idata].weapduration)=vbound(value/10000, 0, 255);
18038 break;
18039
18040 case IDATADUPLICATES:
18041 if(unsigned(ri->idata) >= MAXITEMS)
18042 {
18043 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18044 break;
18045 }
18046 (itemsbuf[ri->idata].duplicates)=vbound(value/10000, 0, 255);
18047 break;
18048 case IDATADRAWLAYER:
18049 if(unsigned(ri->idata) >= MAXITEMS)
18050 {
18051 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18052 break;
18053 }
18054 (itemsbuf[ri->idata].drawlayer)=vbound(value/10000, 0, 7);
18055 break;
18056 case IDATACOLLECTFLAGS:
18057 if(unsigned(ri->idata) >= MAXITEMS)
18058 {
18059 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18060 break;
18061 }
18062 //int32_t a = ri->d[rINDEX] / 10000;
18063 (itemsbuf[ri->idata].collectflags)=vbound(value/10000, 0, 214747);
18064 break;
18065 case IDATAWEAPONSCRIPT:
18066 if(unsigned(ri->idata) >= MAXITEMS)
18067 {
18068 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18069 break;
18070 }
18071 (itemsbuf[ri->idata].weaponscript)=vbound(value/10000, 0, 255);
18072 break;
18073 case IDATAMISCD:
18074 {
18075 if(unsigned(ri->idata) >= MAXITEMS)
18076 {
18077 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18078 break;
18079 }
18080 int32_t a = vbound((ri->d[rINDEX] / 10000),0,31);
18081 (itemsbuf[ri->idata].wpn_misc_d[a])=(value/10000);
18082 }
18083 break;
18084 case IDATAWPNINITD:
18085 {
18086 if(unsigned(ri->idata) >= MAXITEMS)
18087 {
18088 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18089 break;
18090 }
18091 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
18092 (itemsbuf[ri->idata].weap_initiald[a])=(value);
18093 }
18094 break;
18095 case IDATAWEAPHXOFS:
18096 if(unsigned(ri->idata) >= MAXITEMS)
18097 {
18098 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18099 break;
18100 }
18101 (itemsbuf[ri->idata].weap_hxofs)=(value/10000);
18102 break;
18103 case IDATAWEAPHYOFS:
18104 if(unsigned(ri->idata) >= MAXITEMS)
18105 {
18106 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18107 break;
18108 }
18109 (itemsbuf[ri->idata].weap_hyofs)=(value/10000);
18110 break;
18111 case IDATAWEAPHXSZ:
18112 if(unsigned(ri->idata) >= MAXITEMS)
18113 {
18114 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18115 break;
18116 }
18117 (itemsbuf[ri->idata].weap_hxsz)=(value/10000);
18118 break;
18119 case IDATAWEAPHYSZ:
18120 if(unsigned(ri->idata) >= MAXITEMS)
18121 {
18122 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18123 break;
18124 }
18125 (itemsbuf[ri->idata].weap_hysz)=(value/10000);
18126 break;
18127 case IDATAWEAPHZSZ:
18128 if(unsigned(ri->idata) >= MAXITEMS)
18129 {
18130 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18131 break;
18132 }
18133 (itemsbuf[ri->idata].weap_hzsz)=(value/10000);
18134 break;
18135 case IDATAWEAPXOFS:
18136 if(unsigned(ri->idata) >= MAXITEMS)
18137 {
18138 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18139 break;
18140 }
18141 (itemsbuf[ri->idata].weap_xofs)=(value/10000);
18142 break;
18143 case IDATAWEAPYOFS:
18144 if(unsigned(ri->idata) >= MAXITEMS)
18145 {
18146 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18147 break;
18148 }
18149 (itemsbuf[ri->idata].weap_yofs)=(value/10000);
18150 break;
18151
18152
18153 case IDATAHXOFS:
18154 if(unsigned(ri->idata) >= MAXITEMS)
18155 {
18156 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18157 break;
18158 }
18159 (itemsbuf[ri->idata].hxofs)=(value/10000);
18160 break;
18161 case IDATAHYOFS:
18162 if(unsigned(ri->idata) >= MAXITEMS)
18163 {
18164 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18165 break;
18166 }
18167 (itemsbuf[ri->idata].hyofs)=(value/10000);
18168 break;
18169 case IDATAHXSZ:
18170 if(unsigned(ri->idata) >= MAXITEMS)
18171 {
18172 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18173 break;
18174 }
18175 (itemsbuf[ri->idata].hxsz)=(value/10000);
18176 break;
18177 case IDATAHYSZ:
18178 if(unsigned(ri->idata) >= MAXITEMS)
18179 {
18180 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18181 break;
18182 }
18183 (itemsbuf[ri->idata].hysz)=(value/10000);
18184 break;
18185 case IDATAHZSZ:
18186 if(unsigned(ri->idata) >= MAXITEMS)
18187 {
18188 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18189 break;
18190 }
18191 (itemsbuf[ri->idata].hzsz)=(value/10000);
18192 break;
18193 case IDATADXOFS:
18194 if(unsigned(ri->idata) >= MAXITEMS)
18195 {
18196 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18197 break;
18198 }
18199 (itemsbuf[ri->idata].xofs)=(value/10000);
18200 break;
18201 case IDATADYOFS:
18202 if(unsigned(ri->idata) >= MAXITEMS)
18203 {
18204 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18205 break;
18206 }
18207 (itemsbuf[ri->idata].yofs)=(value/10000);
18208 break;
18209 case IDATATILEW:
18210 if(unsigned(ri->idata) >= MAXITEMS)
18211 {
18212 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18213 break;
18214 }
18215 (itemsbuf[ri->idata].tilew)=(value/10000);
18216 break;
18217 case IDATATILEH:
18218 if(unsigned(ri->idata) >= MAXITEMS)
18219 {
18220 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18221 break;
18222 }
18223 (itemsbuf[ri->idata].tileh)=(value/10000);
18224 break;
18225 case IDATAPICKUP:
18226 if(unsigned(ri->idata) >= MAXITEMS)
18227 {
18228 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18229 break;
18230 }
18231 (itemsbuf[ri->idata].pickup)=(value/10000);
18232 break;
18233 case IDATAOVERRIDEFL:
18234 if(unsigned(ri->idata) >= MAXITEMS)
18235 {
18236 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18237 break;
18238 }
18239 (itemsbuf[ri->idata].overrideFLAGS)=(value/10000);
18240 break;
18241
18242 case IDATATILEWWEAP:
18243 if(unsigned(ri->idata) >= MAXITEMS)
18244 {
18245 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18246 break;
18247 }
18248 (itemsbuf[ri->idata].weap_tilew)=(value/10000);
18249 break;
18250 case IDATATILEHWEAP:
18251 if(unsigned(ri->idata) >= MAXITEMS)
18252 {
18253 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18254 break;
18255 }
18256 (itemsbuf[ri->idata].weap_tileh)=(value/10000);
18257 break;
18258 case IDATAOVERRIDEFLWEAP:
18259 if(unsigned(ri->idata) >= MAXITEMS)
18260 {
18261 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18262 break;
18263 }
18264 (itemsbuf[ri->idata].weapoverrideFLAGS)=(value/10000);
18265 break;
18266
18267 case IDATAUSEMVT:
18268 {
18269 if(unsigned(ri->idata) >= MAXITEMS)
18270 {
18271 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18272 break;
18273 }
18274 int32_t a = vbound((ri->d[rINDEX] / 10000),0,(ITEM_MOVEMENT_PATTERNS-1));
18275 (itemsbuf[ri->idata].weap_pattern[a])=vbound(value/10000, 0, 255);
18276 break;
18277 }
18278
18279 case IDATALEVEL:
18280 if(unsigned(ri->idata) >= MAXITEMS)
18281 {
18282 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18283 break;
18284 }
18285 (itemsbuf[ri->idata].fam_type)=vbound(value/10000, 0, 512);
18286 flushItemCache();
18287 break;
18288 case IDATAKEEP:
18289 item_flag(ITEM_GAMEDATA, value);
18290 break;
18291 case IDATAAMOUNT:
18292 {
18293 if(unsigned(ri->idata) >= MAXITEMS)
18294 {
18295 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18296 break;
18297 }
18298 int32_t v = vbound(value/10000, -9999, 16383);
18299 itemsbuf[ri->idata].amount &= 0x8000;
18300 itemsbuf[ri->idata].amount |= (abs(v)&0x3FFF)|(v<0?0x4000:0);
18301 break;
18302 }
18303 case IDATAGRADUAL:
18304 {
18305 if(unsigned(ri->idata) >= MAXITEMS)
18306 {
18307 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18308 break;
18309 }
18310 SETFLAG(itemsbuf[ri->idata].amount, 0x8000, value!=0);
18311 break;
18312 }
18313 case IDATACONSTSCRIPT:
18314 item_flag(ITEM_PASSIVESCRIPT, value);
18315 break;
18316 case IDATASSWIMDISABLED:
18317 item_flag(ITEM_SIDESWIM_DISABLED, value);
18318 break;
18319 case IDATABUNNYABLE:
18320 item_flag(ITEM_BUNNY_ENABLED, value);
18321 break;
18322 case IDATAJINXIMMUNE:
18323 item_flag(ITEM_JINX_IMMUNE, value);
18324 break;
18325 case IDATAJINXSWAP:
18326 item_flag(ITEM_FLIP_JINX, value);
18327 break;
18328 case IDATASETMAX:
18329 if(unsigned(ri->idata) >= MAXITEMS)
18330 {
18331 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18332 break;
18333 }
18334 (itemsbuf[ri->idata].setmax)=value/10000;
18335 break;
18336
18337 case IDATAMAX:
18338 if(unsigned(ri->idata) >= MAXITEMS)
18339 {
18340 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18341 break;
18342 }
18343 (itemsbuf[ri->idata].max)=value/10000;
18344 break;
18345
18346 case IDATAPOWER:
18347 if(unsigned(ri->idata) >= MAXITEMS)
18348 {
18349 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18350 break;
18351 }
18352 (itemsbuf[ri->idata].power)=value/10000;
18353 break;
18354
18355 case IDATACOUNTER:
18356 if(unsigned(ri->idata) >= MAXITEMS)
18357 {
18358 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18359 break;
18360 }
18361 (itemsbuf[ri->idata].count)=vbound(value/10000,0,31);
18362 break;
18363
18364 case IDATAPSOUND:
18365 if(unsigned(ri->idata) >= MAXITEMS)
18366 {
18367 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18368 break;
18369 }
18370 (itemsbuf[ri->idata].playsound)=vbound(value/10000, 0, 255);
18371 break;
18372
18373 case IDATAUSESOUND:
18374 if(unsigned(ri->idata) >= MAXITEMS)
18375 {
18376 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18377 break;
18378 }
18379 (itemsbuf[ri->idata].usesound)=vbound(value/10000, 0, 255);
18380 break;
18381
18382 case IDATAUSESOUND2:
18383 if(unsigned(ri->idata) >= MAXITEMS)
18384 {
18385 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18386 break;
18387 }
18388 (itemsbuf[ri->idata].usesound2)=vbound(value/10000, 0, 255);
18389 break;
18390
18391 //2.54
18392 //My additions begin here. -Z
18393 //Stack item to gain next level
18394 case IDATACOMBINE:
18395 item_flag(ITEM_COMBINE, value);
18396 break;
18397 //using a level of an item downgrades to a lower one
18398 case IDATADOWNGRADE:
18399 item_flag(ITEM_DOWNGRADE, value);
18400 break;
18401 //Only validate the cost, don't charge it
18402 case IDATAVALIDATE:
18403 item_flag(ITEM_VALIDATEONLY, value);
18404 break;
18405 case IDATAVALIDATE2:
18406 item_flag(ITEM_VALIDATEONLY2, value);
18407 break;
18408
18409 //Flags[5]
18410 case IDATAFLAGS:
18411 {
18412 if(unsigned(ri->idata) >= MAXITEMS)
18413 {
18414 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18415 break;
18416 }
18417 int32_t index = ri->d[rINDEX]/10000;
18418 switch(index)
18419 {
18420 case 0:
18421 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG1, value);
18422 break;
18423 case 1:
18424 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG2, value);
18425 break;
18426 case 2:
18427 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG3, value);
18428 break;
18429 case 3:
18430 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG4, value);
18431 break;
18432 case 4:
18433 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG5, value);
18434 break;
18435 case 5:
18436 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG6, value);
18437 break;
18438 case 6:
18439 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG7, value);
18440 break;
18441 case 7:
18442 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG8, value);
18443 break;
18444 case 8:
18445 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG9, value);
18446 break;
18447 case 9:
18448 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG10, value);
18449 break;
18450 case 10:
18451 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG11, value);
18452 break;
18453 case 11:
18454 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG12, value);
18455 break;
18456 case 12:
18457 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG13, value);
18458 break;
18459 case 13:
18460 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG14, value);
18461 break;
18462 case 14:
18463 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG15, value);
18464 break;
18465 case 15:
18466 SETFLAG(itemsbuf[ri->idata].flags, ITEM_PASSIVESCRIPT, value);
18467 break;
18468 }
18469
18470 break;
18471 }
18472 //Keep Old in editor
18473 case IDATAKEEPOLD:
18474 item_flag(ITEM_KEEPOLD, value);
18475 break;
18476 //Ruppes for magic
18477 case IDATARUPEECOST:
18478 item_flag(ITEM_RUPEE_MAGIC, value);
18479 break;
18480 //can be eaten
18481 case IDATAEDIBLE:
18482 item_flag(ITEM_EDIBLE, value);
18483 break;
18484 //Unused at this time
18485 case IDATAFLAGUNUSED:
18486 item_flag(ITEM_UNUSED, value);
18487 break;
18488 //gain lower level items
18489 case IDATAGAINLOWER:
18490 item_flag(ITEM_GAINOLD, value);
18491 break;
18492 //Set the action script
18493 case IDATASCRIPT:
18494 if(unsigned(ri->idata) >= MAXITEMS)
18495 {
18496 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18497 break;
18498 }
18499 FFScript::deallocateAllScriptOwned(ScriptType::Item, ri->idata);
18500 itemsbuf[ri->idata].script=vbound(value/10000,0,255);
18501 break;
18502 case IDATASPRSCRIPT:
18503 if(unsigned(ri->idata) >= MAXITEMS)
18504 {
18505 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18506 break;
18507 }
18508 itemsbuf[ri->idata].sprite_script=vbound(value/10000,0,255);
18509 break;
18510
18511 /*
18512 case ITEMMISCD:
18513 if(0!=(s=checkItem(ri->itemref)))
18514 {
18515 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
18516 (((item*)(s))->miscellaneous[a])=value;
18517 }
18518
18519 break;*/
18520 //Attributes[10]
18521 case IDATAATTRIB: {
18522 if(unsigned(ri->idata) >= MAXITEMS)
18523 {
18524 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18525 break;
18526 }
18527 int32_t index = vbound(ri->d[rINDEX]/10000,0,9);
18528 switch(index)
18529 {
18530 case 0:
18531 itemsbuf[ri->idata].misc1=value/10000;
18532 break;
18533 case 1:
18534 itemsbuf[ri->idata].misc2=value/10000; break;
18535 case 2:
18536 itemsbuf[ri->idata].misc3=value/10000; break;
18537 case 3:
18538 itemsbuf[ri->idata].misc4=value/10000; break;
18539 case 4:
18540 itemsbuf[ri->idata].misc5=value/10000; break;
18541 case 5:
18542 itemsbuf[ri->idata].misc6=value/10000; break;
18543 case 6:
18544 itemsbuf[ri->idata].misc7=value/10000; break;
18545 case 7:
18546 itemsbuf[ri->idata].misc8=value/10000; break;
18547 case 8:
18548 itemsbuf[ri->idata].misc9=value/10000; break;
18549 case 9:
18550 itemsbuf[ri->idata].misc10=value/10000; break;
18551
18552 default:
18553 break;
18554 }
18555
18556 break;
18557 }
18558 //SpriteSprites[10]
18559 case IDATASPRITE:
18560 {
18561 if(unsigned(ri->idata) >= MAXITEMS)
18562 {
18563 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18564 break;
18565 }
18566 int32_t index = vbound(ri->d[rINDEX]/10000,0,9);
18567 switch(index)
18568 {
18569 case 0:
18570 itemsbuf[ri->idata].wpn=vbound(value/10000, 0, 255);
18571 break;
18572 case 1:
18573 itemsbuf[ri->idata].wpn2=vbound(value/10000, 0, 255); break;
18574 case 2:
18575 itemsbuf[ri->idata].wpn3=vbound(value/10000, 0, 255); break;
18576 case 3:
18577 itemsbuf[ri->idata].wpn4=vbound(value/10000, 0, 255); break;
18578 case 4:
18579 itemsbuf[ri->idata].wpn5=vbound(value/10000, 0, 255); break;
18580 case 5:
18581 itemsbuf[ri->idata].wpn6=vbound(value/10000, 0, 255); break;
18582 case 6:
18583 itemsbuf[ri->idata].wpn7=vbound(value/10000, 0, 255); break;
18584 case 7:
18585 itemsbuf[ri->idata].wpn8=vbound(value/10000, 0, 255); break;
18586 case 8:
18587 itemsbuf[ri->idata].wpn9=vbound(value/10000, 0, 255); break;
18588 case 9:
18589 itemsbuf[ri->idata].wpn10=vbound(value/10000, 0, 255); break;
18590
18591 default:
18592 break;
18593 }
18594
18595 break;
18596 }
18597 //Hero tile modifier.
18598 case IDATALTM:
18599 if(unsigned(ri->idata) >= MAXITEMS)
18600 {
18601 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18602 break;
18603 }
18604 itemsbuf[ri->idata].ltm=value/10000;
18605 break;
18606 //Pickup script
18607 case IDATAPSCRIPT:
18608 {
18609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2760 times.
2760 if(unsigned(ri->idata) >= MAXITEMS)
18610 {
18611 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18612 break;
18613 }
18614 //Need to get collect script ref, not standard idata ref!
18615
1/2
✓ Branch 0 taken 2760 times.
✗ Branch 1 not taken.
2760 const int32_t new_ref = ri->idata!=0 ? -(ri->idata) : COLLECT_SCRIPT_ITEM_ZERO;
18616 2760 FFScript::deallocateAllScriptOwned(ScriptType::Item,new_ref);
18617 2760 itemsbuf[ri->idata].collect_script=vbound(value/10000, 0, 255);
18618 2760 break;
18619 }
18620 //pickup string
18621 case IDATAPSTRING:
18622 if(unsigned(ri->idata) >= MAXITEMS)
18623 {
18624 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18625 break;
18626 }
18627 itemsbuf[ri->idata].pstring=vbound(value/10000, 1, 255);
18628 break;
18629 case IDATAPFLAGS:
18630 if(unsigned(ri->idata) >= MAXITEMS)
18631 {
18632 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18633 break;
18634 }
18635 itemsbuf[ri->idata].pickup_string_flags=vbound(value/10000, 0, 214748);
18636 break;
18637 //magic cost
18638 case IDATAMAGCOST:
18639 if(unsigned(ri->idata) >= MAXITEMS)
18640 {
18641 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18642 break;
18643 }
18644 itemsbuf[ri->idata].cost_amount[0]=vbound(value/10000,32767,-32768);
18645 break;
18646 case IDATACOST2:
18647 if(unsigned(ri->idata) >= MAXITEMS)
18648 {
18649 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18650 break;
18651 }
18652 itemsbuf[ri->idata].cost_amount[1]=vbound(value/10000,32767,-32768);
18653 break;
18654 //cost counter ref
18655 case IDATACOSTCOUNTER:
18656 if(unsigned(ri->idata) >= MAXITEMS)
18657 {
18658 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18659 break;
18660 }
18661 itemsbuf[ri->idata].cost_counter[0]=(vbound(value/10000,-1,32));
18662 break;
18663 case IDATACOSTCOUNTER2:
18664 if(unsigned(ri->idata) >= MAXITEMS)
18665 {
18666 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18667 break;
18668 }
18669 itemsbuf[ri->idata].cost_counter[1]=(vbound(value/10000,-1,32));
18670 break;
18671 //min hearts to pick up
18672 case IDATAMINHEARTS:
18673 if(unsigned(ri->idata) >= MAXITEMS)
18674 {
18675 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18676 break;
18677 }
18678 itemsbuf[ri->idata].pickup_hearts=vbound(value/10000, 0, 214748);
18679 break;
18680 //item tile
18681 case IDATATILE:
18682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(unsigned(ri->idata) >= MAXITEMS)
18683 {
18684 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18685 break;
18686 }
18687 70 itemsbuf[ri->idata].tile=vbound(value/10000, 0, 65519);
18688 70 break;
18689 //flash
18690 case IDATAMISC:
18691 if(unsigned(ri->idata) >= MAXITEMS)
18692 {
18693 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18694 break;
18695 }
18696 itemsbuf[ri->idata].misc_flags=value/10000;
18697 break;
18698 //cset
18699 case IDATACSET:
18700 if(unsigned(ri->idata) >= MAXITEMS)
18701 {
18702 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18703 break;
18704 }
18705 itemsbuf[ri->idata].csets=vbound(value/10000,0,13);
18706 break;
18707 /*
18708 case IDATAFRAME:
18709 itemsbuf[ri->idata].frame=value/10000;
18710 break;
18711 */
18712 //A.Frames
18713 case IDATAFRAMES:
18714 if(unsigned(ri->idata) >= MAXITEMS)
18715 {
18716 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18717 break;
18718 }
18719 (itemsbuf[ri->idata].frames)=vbound(value/10000, 0, 214748);
18720 break;
18721 //A.speed
18722 case IDATAASPEED:
18723 if(unsigned(ri->idata) >= MAXITEMS)
18724 {
18725 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18726 break;
18727 }
18728 itemsbuf[ri->idata].speed=vbound(value/10000, 0, 214748);
18729 break;
18730 //Anim delay
18731 case IDATADELAY:
18732 if(unsigned(ri->idata) >= MAXITEMS)
18733 {
18734 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18735 break;
18736 }
18737 itemsbuf[ri->idata].delay=vbound(value/10000, 0, 214748);
18738 break;
18739
18740 //not one of mine.
18741 case IDATAINITDD:
18742 {
18743 int32_t a = ri->d[rINDEX] / 10000;
18744 if(unsigned(ri->idata) >= MAXITEMS)
18745 {
18746 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
18747 break;
18748 }
18749
18750 if(BC::checkBounds(a, 0, 7, "itemdata->InitD") == SH::_NoError)
18751 itemsbuf[ri->idata].initiald[a] = value;
18752 }
18753 break;
18754
18755 ///----------------------------------------------------------------------------------------------------//
18756 //LWeapon Variables
18757
18758 case LWPNSCALE:
18759 if ( get_qr(qr_OLDSPRITEDRAWS) )
18760 {
18761 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
18762 "lweapon->Scale");
18763 break;
18764 }
18765 if(0!=(s=checkLWpn(ri->lwpn,"Scale")))
18766 ((weapon*)s)->scale=(zfix)(value/100.0);
18767
18768 break;
18769
18770 case LWPNX:
18771
2/2
✓ Branch 0 taken 6717 times.
✓ Branch 1 taken 187039 times.
193756 if(0!=(s=checkLWpn(ri->lwpn,"X")))
18772
2/2
✓ Branch 0 taken 61588 times.
✓ Branch 1 taken 125451 times.
187039 ((weapon*)s)->x=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
18773 193756 break;
18774
18775 case SPRITEMAXLWPN:
18776 {
18777 //No bounds check, as this is a universal function and works from NULL pointers!
18778 1 Lwpns.setMax(vbound((value/10000),1,MAX_LWPN_SPRITES));
18779 1 break;
18780 }
18781
18782 case LWPNY:
18783
2/2
✓ Branch 0 taken 6717 times.
✓ Branch 1 taken 187032 times.
193749 if(0!=(s=checkLWpn(ri->lwpn,"Y")))
18784
2/2
✓ Branch 0 taken 61588 times.
✓ Branch 1 taken 125444 times.
187032 ((weapon*)s)->y=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
18785
18786 193749 break;
18787
18788 case LWPNZ:
18789 if(0!=(s=checkLWpn(ri->lwpn,"Z")))
18790 {
18791 ((weapon*)s)->z=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
18792 if(((weapon*)s)->z < 0) ((weapon*)s)->z = 0_zf;
18793 }
18794
18795 break;
18796
18797 case LWPNJUMP:
18798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if(0!=(s=checkLWpn(ri->lwpn,"Jump")))
18799 180 ((weapon*)s)->fall=zslongToFix(value)*-100;
18800
18801 180 break;
18802
18803 case LWPNFAKEJUMP:
18804 if(0!=(s=checkLWpn(ri->lwpn,"FakeJump")))
18805 ((weapon*)s)->fakefall=zslongToFix(value)*-100;
18806
18807 break;
18808
18809 case LWPNDIR:
18810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65054 times.
65054 if(0!=(s=checkLWpn(ri->lwpn,"Dir")))
18811 {
18812 65054 ((weapon*)s)->dir=(value/10000);
18813 65054 ((weapon*)s)->doAutoRotate(true);
18814 65054 }
18815
18816 65054 break;
18817
18818 case LWPNSPECIAL:
18819 if(0!=(s=checkLWpn(ri->lwpn,"Special")))
18820 ((weapon*)s)->specialinfo=(value/10000);
18821
18822 break;
18823
18824 case LWPNGRAVITY:
18825 if(0!=(s=checkLWpn(ri->lwpn,"Gravity")))
18826 {
18827 if(value)
18828 ((weapon*)s)->moveflags |= FLAG_OBEYS_GRAV;
18829 else
18830 ((weapon*)s)->moveflags &= ~FLAG_OBEYS_GRAV;
18831 }
18832 break;
18833
18834 case LWPNSTEP:
18835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8276 times.
8276 if(0!=(s=checkLWpn(ri->lwpn,"Step")))
18836 {
18837 // fp math is bad for replay, so always ignore this QR when replay is active.
18838 // TODO: can we just delete this QR? Would it actually break anything? For now,
18839 // just disable for replay and wait for more tests to be played with this QR
18840 // ignored.
18841
3/4
✓ Branch 0 taken 7031 times.
✓ Branch 1 taken 1245 times.
✓ Branch 2 taken 7031 times.
✗ Branch 3 not taken.
8276 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
18842 {
18843 8276 ((weapon*)s)->step= zslongToFix(value / 100);
18844 8276 }
18845 else
18846 {
18847 //old, buggy code replication, round two: Go! -Z
18848 //zfix val = zslongToFix(value);
18849 //val.doFloor();
18850 //((weapon*)s)->step = ((val / 100.0).getFloat());
18851
18852 //old, buggy code replication, round THREE: Go! -Z
18853 ((weapon*)s)->step = ((value/10000)/100.0);
18854 }
18855
18856 8276 }
18857
18858 8276 break;
18859
18860 case LWPNANGLE:
18861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1469 times.
1469 if(0!=(s=checkLWpn(ri->lwpn,"Angle")))
18862 {
18863 1469 ((weapon*)s)->angle=(double)(value/10000.0);
18864 1469 ((weapon*)(s))->doAutoRotate();
18865 1469 }
18866
18867 1469 break;
18868
18869 case LWPNDEGANGLE:
18870 if(0!=(s=checkLWpn(ri->lwpn,"DegAngle")))
18871 {
18872 double rangle = (value / 10000.0) * (PI / 180.0);
18873 ((weapon*)s)->angle=(double)(rangle);
18874 ((weapon*)(s))->doAutoRotate();
18875 }
18876
18877 break;
18878
18879 case LWPNVX:
18880 if(0!=(s=checkLWpn(ri->lwpn,"Vx")))
18881 {
18882 double vy;
18883 double vx = (value / 10000.0);
18884 if (((weapon*)(s))->angular)
18885 vy = zc::math::Sin(((weapon*)s)->angle)*((weapon*)s)->step;
18886 else
18887 {
18888 switch(NORMAL_DIR(((weapon*)(s))->dir))
18889 {
18890 case l_up:
18891 case r_up:
18892 case up:
18893 vy = -1.0*((weapon*)s)->step;
18894 break;
18895 case l_down:
18896 case r_down:
18897 case down:
18898 vy = ((weapon*)s)->step;
18899 break;
18900
18901 default:
18902 vy = 0;
18903 break;
18904 }
18905 }
18906 ((weapon*)s)->angular = true;
18907 ((weapon*)s)->angle=atan2(vy, vx);
18908 ((weapon*)s)->step=FFCore.Distance(0, 0, vx, vy)/10000.0;
18909 ((weapon*)(s))->doAutoRotate();
18910 }
18911
18912 break;
18913
18914 case LWPNVY:
18915 if(0!=(s=checkLWpn(ri->lwpn,"Vy")))
18916 {
18917 double vx;
18918 double vy = (value / 10000.0);
18919 if (((weapon*)(s))->angular)
18920 vx = zc::math::Cos(((weapon*)s)->angle)*((weapon*)s)->step;
18921 else
18922 {
18923 switch(NORMAL_DIR(((weapon*)(s))->dir))
18924 {
18925 case l_up:
18926 case l_down:
18927 case left:
18928 vx = -1.0*((weapon*)s)->step;
18929 break;
18930 case r_down:
18931 case r_up:
18932 case right:
18933 vx = ((weapon*)s)->step;
18934 break;
18935
18936 default:
18937 vx = 0;
18938 break;
18939 }
18940 }
18941 ((weapon*)s)->angular = true;
18942 ((weapon*)s)->angle=atan2(vy, vx);
18943 ((weapon*)s)->step=FFCore.Distance(0, 0, vx, vy)/10000.0;
18944 ((weapon*)(s))->doAutoRotate();
18945 }
18946
18947 break;
18948
18949 case LWPNANGULAR:
18950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1175 times.
1175 if(0!=(s=checkLWpn(ri->lwpn,"Angular")))
18951 {
18952 1175 ((weapon*)s)->angular=(value!=0);
18953 1175 ((weapon*)(s))->doAutoRotate(false, true);
18954 1175 }
18955
18956 1175 break;
18957
18958 case LWPNAUTOROTATE:
18959 if(0!=(s=checkLWpn(ri->lwpn,"AutoRotate")))
18960 {
18961 ((weapon*)s)->autorotate=(value!=0);
18962 ((weapon*)(s))->doAutoRotate(false, true);
18963 }
18964
18965 break;
18966
18967 case LWPNBEHIND:
18968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(0!=(s=checkLWpn(ri->lwpn,"Behind")))
18969 16 ((weapon*)s)->behind=(value!=0);
18970
18971 16 break;
18972
18973 case LWPNDRAWTYPE:
18974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 if(0!=(s=checkLWpn(ri->lwpn,"DrawStyle")))
18975 49 ((weapon*)s)->drawstyle=(value/10000);
18976
18977 49 break;
18978
18979 case LWPNPOWER:
18980
1/2
✓ Branch 0 taken 69347 times.
✗ Branch 1 not taken.
69347 if(0!=(s=checkLWpn(ri->lwpn,"Damage")))
18981 69347 ((weapon*)s)->power=(value/10000);
18982
18983 69347 break;
18984 /*
18985 case LWPNRANGE:
18986 if(0!=(s=checkLWpn(ri->lwpn,"Range")))
18987 ((weapon*)s)->scriptrange=vbound((value/10000),0,512); //Allow it to move off-screen. -Z
18988 break;
18989 */
18990 case LWPNDEAD:
18991
2/2
✓ Branch 0 taken 6717 times.
✓ Branch 1 taken 132457 times.
139174 if(0!=(s=checkLWpn(ri->lwpn,"DeadState")))
18992 {
18993 132457 auto dead = value/10000;
18994 132457 ((weapon*)s)->dead=dead;
18995
2/2
✓ Branch 0 taken 68348 times.
✓ Branch 1 taken 64109 times.
132457 if(dead != 0) ((weapon*)s)->weapon_dying_frame = false;
18996 132457 }
18997 139174 break;
18998
18999 case LWPNID:
19000 if(0!=(s=checkLWpn(ri->lwpn,"ID")))
19001 ((weapon*)s)->id=(value/10000);
19002
19003 break;
19004
19005 case LWPNTILE:
19006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1853 times.
1853 if(0!=(s=checkLWpn(ri->lwpn,"Tile")))
19007 1853 ((weapon*)s)->tile=(value/10000);
19008
19009 1853 break;
19010
19011 case LWPNSCRIPTTILE:
19012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3221 times.
3221 if(0!=(s=checkLWpn(ri->lwpn,"ScriptTile")))
19013 3221 ((weapon*)s)->scripttile=vbound((value/10000),-1,NEWMAXTILES-1);
19014
19015 3221 break;
19016
19017 case LWPNSCRIPTFLIP:
19018 if(0!=(s=checkLWpn(ri->lwpn,"ScriptFlip")))
19019 ((weapon*)s)->scriptflip=vbound((value/10000),-1,127);
19020
19021 break;
19022
19023 case LWPNCSET:
19024
1/2
✓ Branch 0 taken 2065 times.
✗ Branch 1 not taken.
2065 if(0!=(s=checkLWpn(ri->lwpn,"CSet")))
19025 2065 ((weapon*)s)->cs=(value/10000)&15;
19026
19027 2065 break;
19028
19029 case LWPNFLASHCSET:
19030 if(0!=(s=checkLWpn(ri->lwpn,"FlashCSet")))
19031 (((weapon*)s)->o_cset)|=(value/10000)<<4;
19032
19033 break;
19034
19035 case LWPNFRAMES:
19036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 404 times.
404 if(0!=(s=checkLWpn(ri->lwpn,"NumFrames")))
19037 404 ((weapon*)s)->frames=(value/10000);
19038
19039 404 break;
19040
19041 case LWPNFRAME:
19042 if(0!=(s=checkLWpn(ri->lwpn,"Frame")))
19043 ((weapon*)s)->aframe=(value/10000);
19044
19045 break;
19046
19047 case LWPNASPEED:
19048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(0!=(s=checkLWpn(ri->lwpn,"ASpeed")))
19049 457 ((weapon*)s)->o_speed=(value/10000);
19050
19051 457 break;
19052
19053 case LWPNFLASH:
19054 if(0!=(s=checkLWpn(ri->lwpn,"Flash")))
19055 ((weapon*)s)->flash=(value/10000);
19056
19057 break;
19058
19059 case LWPNFLIP:
19060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 683 times.
683 if(0!=(s=checkLWpn(ri->lwpn,"Flip")))
19061 683 ((weapon*)s)->flip=(value/10000);
19062
19063 683 break;
19064
19065 case LWPNROTATION:
19066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4922 times.
4922 if ( get_qr(qr_OLDSPRITEDRAWS) )
19067 {
19068 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
19069 "lweapon->Rotation");
19070 break;
19071 }
19072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4922 times.
4922 if(0!=(s=checkLWpn(ri->lwpn,"Rotation")))
19073 4922 ((weapon*)s)->rotation=(value/10000);
19074
19075 4922 break;
19076
19077 case LWPNEXTEND:
19078
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(0!=(s=checkLWpn(ri->lwpn,"Extend")))
19079 16 ((weapon*)s)->extend=(value/10000);
19080
19081 16 break;
19082
19083 case LWPNOTILE:
19084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1841 times.
1841 if(0!=(s=checkLWpn(ri->lwpn,"OriginalTile")))
19085 {
19086 //zprint("LWPNOTILE before write: %d\n", ((weapon*)s)->o_tile);
19087 1841 ((weapon*)s)->o_tile=(value/10000);
19088 1841 ((weapon*)s)->ref_o_tile=(value/10000);
19089 //((weapon*)s)->script_wrote_otile=1; //Removing this as of 26th October, 2019 -Z
19090 //if at some future point we WANT writing ->Tile to also overwrite ->OriginalTile,
19091 //then either the user will need to manually write tile, or we can add a QR and
19092 // write ->tile here. 'script_wrote_otile' is out.
19093 //zprint("LWPNOTILE after write: %d\n", ((weapon*)s)->o_tile);
19094 1841 }
19095 1841 break;
19096
19097 case LWPNOCSET:
19098 if(0!=(s=checkLWpn(ri->lwpn,"OriginalCSet")))
19099 (((weapon*)s)->o_cset)|=(value/10000)&15;
19100
19101 break;
19102
19103 case LWPNHXOFS:
19104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60616 times.
60616 if(0!=(s=checkLWpn(ri->lwpn,"HitXOffset")))
19105 60616 (((weapon*)s)->hxofs)=(value/10000);
19106
19107 60616 break;
19108
19109 case LWPNHYOFS:
19110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60616 times.
60616 if(0!=(s=checkLWpn(ri->lwpn,"HitYOffset")))
19111 60616 (((weapon*)s)->hyofs)=(value/10000);
19112
19113 60616 break;
19114
19115 case LWPNXOFS:
19116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
156 if(0!=(s=checkLWpn(ri->lwpn,"DrawXOffset")))
19117 156 (((weapon*)s)->xofs)=(zfix)(value/10000);
19118
19119 156 break;
19120
19121 case LWPNYOFS:
19122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63470 times.
63470 if(0!=(s=checkLWpn(ri->lwpn,"DrawYOffset")))
19123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63470 times.
63470 (((weapon*)s)->yofs)=(zfix)(value/10000)+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
19124
19125 63470 break;
19126
19127 case LWPNSHADOWXOFS:
19128 if(0!=(s=checkLWpn(ri->lwpn,"ShadowXOffset")))
19129 (((weapon*)s)->shadowxofs)=(zfix)(value/10000);
19130
19131 break;
19132
19133 case LWPNSHADOWYOFS:
19134 if(0!=(s=checkLWpn(ri->lwpn,"ShadowYOffset")))
19135 (((weapon*)s)->shadowyofs)=(zfix)(value/10000);
19136
19137 break;
19138
19139 case LWPNTOTALDYOFFS:
19140 break; //READ-ONLY
19141
19142 case LWPNZOFS:
19143 if(0!=(s=checkLWpn(ri->lwpn,"DrawZOffset")))
19144 (((weapon*)s)->zofs)=(zfix)(value/10000);
19145
19146 break;
19147
19148 case LWPNHXSZ:
19149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61740 times.
61740 if(0!=(s=checkLWpn(ri->lwpn,"HitWidth")))
19150 61740 (((weapon*)s)->hit_width)=(value/10000);
19151
19152 61740 break;
19153
19154 case LWPNHYSZ:
19155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61757 times.
61757 if(0!=(s=checkLWpn(ri->lwpn,"HitHeight")))
19156 61757 (((weapon*)s)->hit_height)=(value/10000);
19157
19158 61757 break;
19159
19160 case LWPNHZSZ:
19161 if(0!=(s=checkLWpn(ri->lwpn,"HitZHeight")))
19162 (((weapon*)s)->hzsz)=(value/10000);
19163
19164 break;
19165
19166 case LWPNTXSZ:
19167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(0!=(s=checkLWpn(ri->lwpn,"TileWidth")))
19168 10 (((weapon*)s)->txsz)=vbound((value/10000),1,20);
19169
19170 10 break;
19171
19172 case LWPNTYSZ:
19173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(0!=(s=checkLWpn(ri->lwpn,"TileHeight")))
19174 10 (((weapon*)s)->tysz)=vbound((value/10000),1,20);
19175
19176 10 break;
19177
19178 case LWPNMISCD:
19179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497624 times.
497624 if(0!=(s=checkLWpn(ri->lwpn,"Misc")))
19180 {
19181 497624 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
19182 497624 (((weapon*)(s))->miscellaneous[a])=value;
19183 497624 }
19184
19185 497624 break;
19186
19187 case LWPNCOLLDET:
19188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16120 times.
16120 if(0!=(s=checkLWpn(ri->lwpn,"CollDetection")))
19189 16120 (((weapon*)(s))->scriptcoldet)=value/10000;
19190
19191 16120 break;
19192
19193 case LWPNENGINEANIMATE:
19194 if(0!=(s=checkLWpn(ri->lwpn,"Animation")))
19195 (((weapon*)(s))->do_animation)=(value ? 1 : 0);
19196
19197 break;
19198
19199 case LWPNPARENT:
19200 {
19201 //int32_t pitm = (vbound(value/10000,1,(MAXITEMS-1)));
19202 //zprint("Attempting to set ParentItem to: %d\n", pitm);
19203
19204 if(0!=(s=checkLWpn(ri->lwpn,"Parent")))
19205 (((weapon*)(s))->parentitem)=(vbound(value/10000,-1,(MAXITEMS-1)));
19206 break;
19207 }
19208
19209 case LWPNLEVEL:
19210 if(0!=(s=checkLWpn(ri->lwpn,"Level")))
19211 (((weapon*)(s))->type)=value/10000;
19212
19213 break;
19214
19215 case LWPNSCRIPT:
19216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60902 times.
60902 if(0!=(s=checkLWpn(ri->lwpn,"Script")))
19217 {
19218 60902 FFScript::deallocateAllScriptOwned(ScriptType::Lwpn, ri->lwpn);
19219 60902 (((weapon*)(s))->weaponscript)=vbound(value/10000,0,NUMSCRIPTWEAPONS-1);
19220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60902 times.
60902 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
19221 {
19222
2/2
✓ Branch 0 taken 487216 times.
✓ Branch 1 taken 60902 times.
548118 for(int32_t q=0; q<8; q++)
19223 487216 (((weapon*)(s))->weap_initd[q]) = 0;
19224 60902 }
19225 60902 }
19226 60902 break;
19227
19228 case LWPNUSEWEAPON:
19229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 603 times.
603 if(0!=(s=checkLWpn(ri->lwpn,"Weapon")))
19230 603 (((weapon*)(s))->useweapon)=vbound(value/10000,0,255);
19231
19232 603 break;
19233
19234 case LWPNUSEDEFENCE:
19235 if(0!=(s=checkLWpn(ri->lwpn,"Defense")))
19236 (((weapon*)(s))->usedefence)=vbound(value/10000,0,255);
19237
19238 break;
19239
19240 case LWPNINITD:
19241 {
19242 238 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
19243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 238 times.
238 if(0!=(s=checkLWpn(ri->lwpn,"InitD[]")))
19244 {
19245 238 (((weapon*)(s))->weap_initd[a])=value;
19246 238 }
19247 238 break;
19248 }
19249 case LWPNFALLCLK:
19250 if(0!=(s=checkLWpn(ri->lwpn,"Falling")))
19251 {
19252 if(((weapon*)(s))->fallclk != 0 && value == 0)
19253 {
19254 ((weapon*)(s))->cs = ((weapon*)(s))->old_cset;
19255 ((weapon*)(s))->tile = ((weapon*)(s))->o_tile;
19256 }
19257 else if(((weapon*)(s))->fallclk == 0 && value != 0) ((weapon*)(s))->old_cset = ((weapon*)(s))->cs;
19258 ((weapon*)(s))->fallclk = vbound(value/10000,0,70);
19259 }
19260 break;
19261 case LWPNFALLCMB:
19262 if(0!=(s=checkLWpn(ri->lwpn,"FallCombo")))
19263 {
19264 ((weapon*)(s))->fallCombo = vbound(value/10000,0,MAXCOMBOS-1);
19265 }
19266 break;
19267 case LWPNDROWNCLK:
19268 if(0!=(s=checkLWpn(ri->lwpn,"Drowning")))
19269 {
19270 if(((weapon*)(s))->drownclk != 0 && value == 0)
19271 {
19272 ((weapon*)(s))->cs = ((weapon*)(s))->old_cset;
19273 ((weapon*)(s))->tile = ((weapon*)(s))->o_tile;
19274 }
19275 else if(((weapon*)(s))->drownclk == 0 && value != 0) ((weapon*)(s))->old_cset = ((weapon*)(s))->cs;
19276 ((weapon*)(s))->drownclk = vbound(value/10000,0,70);
19277 }
19278 break;
19279 case LWPNDROWNCMB:
19280 if(0!=(s=checkLWpn(ri->lwpn,"DrownCombo")))
19281 {
19282 ((weapon*)(s))->drownCombo = vbound(value/10000,0,MAXCOMBOS-1);
19283 }
19284 break;
19285 case LWPNFAKEZ:
19286 if(0!=(s=checkLWpn(ri->lwpn,"FakeZ")))
19287 {
19288 ((weapon*)s)->fakez=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
19289 if(((weapon*)s)->fakez < 0) ((weapon*)s)->fakez = 0_zf;
19290 }
19291
19292 break;
19293
19294 case LWPNMOVEFLAGS:
19295 {
19296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 265 times.
265 if(0!=(s=checkLWpn(ri->lwpn,"MoveFlags[]")))
19297 {
19298 265 int32_t indx = ri->d[rINDEX]/10000;
19299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 265 times.
265 if(BC::checkBounds(indx, 0, 10, "lweapon->MoveFlags[]") == SH::_NoError)
19300 {
19301 //All bits, in order, of a single byte; just use bitwise
19302 265 int32_t bit = 1<<indx;
19303
1/2
✓ Branch 0 taken 265 times.
✗ Branch 1 not taken.
265 if(value)
19304 ((weapon*)(s))->moveflags |= bit;
19305 else
19306 265 ((weapon*)(s))->moveflags &= ~bit;
19307 265 }
19308 265 }
19309 265 break;
19310 }
19311 case LWPNFLAGS:
19312 {
19313 if(0!=(s=checkLWpn(ri->lwpn,"Flags[]")))
19314 {
19315 int32_t indx = ri->d[rINDEX]/10000;
19316 if(BC::checkBounds(indx, 0, WFLAG_MAX, "lweapon->Flags[]") == SH::_NoError)
19317 {
19318 //All bits, in order, of a single byte; just use bitwise
19319 int32_t bit = 1<<indx;
19320 if(value)
19321 ((weapon*)(s))->misc_wflags |= bit;
19322 else
19323 ((weapon*)(s))->misc_wflags &= ~bit;
19324 }
19325 }
19326 break;
19327 }
19328
19329 case LWPNGLOWRAD:
19330 if(0!=(s=checkLWpn(ri->lwpn,"LightRadius")))
19331 {
19332 ((weapon*)(s))->glowRad = vbound(value/10000,0,255);
19333 }
19334 break;
19335
19336 case LWPNGLOWSHP:
19337 if(0!=(s=checkLWpn(ri->lwpn,"LightShape")))
19338 {
19339 ((weapon*)(s))->glowShape = vbound(value/10000,0,255);
19340 }
19341 break;
19342
19343 case LWPNUNBL:
19344 if(0!=(s=checkLWpn(ri->lwpn,"Unblockable")))
19345 {
19346 ((weapon*)(s))->unblockable = (value/10000)&WPNUNB_ALL;
19347 }
19348 break;
19349
19350 case LWPNSHADOWSPR:
19351 if(0!=(s=checkLWpn(ri->lwpn,"ShadowSprite")))
19352 {
19353 ((weapon*)(s))->spr_shadow = vbound(value/10000, 0, 255);
19354 }
19355 break;
19356 case LWSWHOOKED:
19357 break; //read-only
19358 case LWPNTIMEOUT:
19359 if(0!=(s=checkLWpn(ri->lwpn,"Timeout")))
19360 {
19361 ((weapon*)(s))->weap_timeout = vbound(value/10000,0,214748);
19362 }
19363 break;
19364 case LWPNDEATHITEM:
19365 if(0!=(s=checkLWpn(ri->lwpn,"DeathItem")))
19366 {
19367 ((weapon*)(s))->death_spawnitem = vbound(value/10000,-1,MAXITEMS-1);
19368 }
19369 break;
19370 case LWPNDEATHDROPSET:
19371 if(0!=(s=checkLWpn(ri->lwpn,"DeathDropset")))
19372 {
19373 ((weapon*)(s))->death_spawndropset = vbound(value/10000,-1,MAXITEMDROPSETS-1);
19374 }
19375 break;
19376 case LWPNDEATHIPICKUP:
19377 if(0!=(s=checkLWpn(ri->lwpn,"DeathItemPFlags")))
19378 {
19379 ((weapon*)(s))->death_item_pflags = value/10000;
19380 }
19381 break;
19382 case LWPNDEATHSPRITE:
19383 if(0!=(s=checkLWpn(ri->lwpn,"DeathSprite")))
19384 {
19385 ((weapon*)(s))->death_sprite = vbound(value/10000,-255,MAXWPNS-1);
19386 }
19387 break;
19388 case LWPNDEATHSFX:
19389 if(0!=(s=checkLWpn(ri->lwpn,"DeathSFX")))
19390 {
19391 ((weapon*)(s))->death_sfx = vbound(value/10000,0,WAV_COUNT);
19392 }
19393 break;
19394 case LWPNLIFTLEVEL:
19395 if(0!=(s=checkLWpn(ri->lwpn,"LiftLevel")))
19396 {
19397 ((weapon*)(s))->lift_level = vbound(value/10000,0,255);
19398 }
19399 break;
19400 case LWPNLIFTTIME:
19401 if(0!=(s=checkLWpn(ri->lwpn,"LiftTime")))
19402 {
19403 ((weapon*)(s))->lift_time = vbound(value/10000,0,255);
19404 }
19405 break;
19406 case LWPNLIFTHEIGHT:
19407 if(0!=(s=checkLWpn(ri->lwpn,"LiftHeight")))
19408 {
19409 ((weapon*)(s))->lift_height = zslongToFix(value);
19410 }
19411 break;
19412
19413 ///----------------------------------------------------------------------------------------------------//
19414 //EWeapon Variables
19415 case EWPNSCALE:
19416 if ( get_qr(qr_OLDSPRITEDRAWS) )
19417 {
19418 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
19419 "eweapon->Scale");
19420 break;
19421 }
19422 if(0!=(s=checkEWpn(ri->ewpn,"Scale")))
19423 ((weapon*)s)->scale=(zfix)(value/100.0);
19424
19425 break;
19426
19427 case EWPNX:
19428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226569 times.
226569 if(0!=(s=checkEWpn(ri->ewpn,"X")))
19429
2/2
✓ Branch 0 taken 7282 times.
✓ Branch 1 taken 219287 times.
226569 ((weapon*)s)->x = (get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
19430
19431 226569 break;
19432
19433 case SPRITEMAXEWPN:
19434 {
19435 //No bounds check, as this is a universal function and works from NULL pointers!
19436 1 Ewpns.setMax(vbound((value/10000),1,MAX_EWPN_SPRITES));
19437 1 break;
19438 }
19439
19440 case EWPNY:
19441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226856 times.
226856 if(0!=(s=checkEWpn(ri->ewpn,"Y")))
19442
2/2
✓ Branch 0 taken 7170 times.
✓ Branch 1 taken 219686 times.
226856 ((weapon*)s)->y = (get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
19443
19444 226856 break;
19445
19446 case EWPNZ:
19447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6823 times.
6823 if(0!=(s=checkEWpn(ri->ewpn,"Z")))
19448 {
19449
2/2
✓ Branch 0 taken 1203 times.
✓ Branch 1 taken 5620 times.
6823 ((weapon*)s)->z=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
19450
1/2
✓ Branch 0 taken 6823 times.
✗ Branch 1 not taken.
6823 if(((weapon*)s)->z < 0) ((weapon*)s)->z = 0_zf;
19451 6823 }
19452
19453 6823 break;
19454
19455 case EWPNJUMP:
19456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6048 times.
6048 if(0!=(s=checkEWpn(ri->ewpn,"Jump")))
19457 6048 ((weapon*)s)->fall=zslongToFix(value)*-100;
19458
19459 6048 break;
19460
19461 case EWPNFAKEJUMP:
19462 if(0!=(s=checkEWpn(ri->ewpn,"FakeJump")))
19463 ((weapon*)s)->fakefall=zslongToFix(value)*-100;
19464
19465 break;
19466
19467 case EWPNDIR:
19468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138270 times.
138270 if(0!=(s=checkEWpn(ri->ewpn,"Dir")))
19469 {
19470 138270 ((weapon*)s)->dir=(value/10000);
19471 138270 ((weapon*)s)->doAutoRotate(true);
19472 138270 }
19473
19474 138270 break;
19475
19476 case EWPNLEVEL:
19477 if(0!=(s=checkEWpn(ri->ewpn,"Level")))
19478 ((weapon*)s)->type=(value/10000);
19479
19480 break;
19481
19482 case EWPNGRAVITY:
19483 if(0!=(s=checkEWpn(ri->ewpn,"Gravity")))
19484 {
19485 if(value)
19486 ((weapon*)s)->moveflags |= FLAG_OBEYS_GRAV;
19487 else
19488 ((weapon*)s)->moveflags &= ~FLAG_OBEYS_GRAV;
19489 }
19490 break;
19491
19492 case EWPNSTEP:
19493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264908 times.
264908 if(0!=(s=checkEWpn(ri->ewpn,"Step")))
19494 {
19495
3/4
✓ Branch 0 taken 243133 times.
✓ Branch 1 taken 21775 times.
✓ Branch 2 taken 243133 times.
✗ Branch 3 not taken.
264908 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
19496 {
19497 264908 ((weapon*)s)->step= zslongToFix(value / 100);
19498 264908 }
19499 else
19500 {
19501 //old, buggy code replication, round two: Go! -Z
19502 //zfix val = zslongToFix(value);
19503 //val.doFloor();
19504 //((weapon*)s)->step = ((val / 100.0).getFloat());
19505
19506 //old, buggy code replication, round THREE: Go! -Z
19507 ((weapon*)s)->step = ((value/10000)/100.0);
19508 //zprint2("ewpn step is %d\n", ((weapon*)s)->step);
19509 }
19510 264908 }
19511
19512 264908 break;
19513
19514 case EWPNANGLE:
19515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134925 times.
134925 if(0!=(s=checkEWpn(ri->ewpn,"Angle")))
19516 {
19517 134925 ((weapon*)s)->angle=(double)(value/10000.0);
19518 134925 ((weapon*)(s))->doAutoRotate();
19519 134925 }
19520
19521 134925 break;
19522
19523 case EWPNDEGANGLE:
19524 if(0!=(s=checkEWpn(ri->ewpn,"DegAngle")))
19525 {
19526 double rangle = (value / 10000.0) * (PI / 180.0);
19527 ((weapon*)s)->angle=(double)(rangle);
19528 ((weapon*)(s))->doAutoRotate();
19529 }
19530
19531 break;
19532
19533 case EWPNVX:
19534 if(0!=(s=checkEWpn(ri->ewpn,"Vx")))
19535 {
19536 double vy;
19537 double vx = (value / 10000.0);
19538 if (((weapon*)(s))->angular)
19539 vy = zc::math::Sin(((weapon*)s)->angle)*((weapon*)s)->step;
19540 else
19541 {
19542 switch(NORMAL_DIR(((weapon*)(s))->dir))
19543 {
19544 case l_up:
19545 case r_up:
19546 case up:
19547 vy = -1.0*((weapon*)s)->step;
19548 break;
19549 case l_down:
19550 case r_down:
19551 case down:
19552 vy = ((weapon*)s)->step;
19553 break;
19554
19555 default:
19556 vy = 0;
19557 break;
19558 }
19559 }
19560 ((weapon*)s)->angular = true;
19561 ((weapon*)s)->angle=atan2(vy, vx);
19562 ((weapon*)s)->step=FFCore.Distance(0, 0, vx, vy)/10000;
19563 ((weapon*)(s))->doAutoRotate();
19564 }
19565
19566 break;
19567
19568 case EWPNVY:
19569 if(0!=(s=checkEWpn(ri->ewpn,"Vy")))
19570 {
19571 double vx;
19572 double vy = (value / 10000.0);
19573 if (((weapon*)(s))->angular)
19574 vx = zc::math::Cos(((weapon*)s)->angle)*((weapon*)s)->step;
19575 else
19576 {
19577 switch(NORMAL_DIR(((weapon*)(s))->dir))
19578 {
19579 case l_up:
19580 case l_down:
19581 case left:
19582 vx = -1.0*((weapon*)s)->step;
19583 break;
19584 case r_down:
19585 case r_up:
19586 case right:
19587 vx = ((weapon*)s)->step;
19588 break;
19589
19590 default:
19591 vx = 0;
19592 break;
19593 }
19594 }
19595 ((weapon*)s)->angular = true;
19596 ((weapon*)s)->angle=atan2(vy, vx);
19597 ((weapon*)s)->step=FFCore.Distance(0, 0, vx, vy)/10000;
19598 ((weapon*)(s))->doAutoRotate();
19599 }
19600
19601 break;
19602
19603 case EWPNANGULAR:
19604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131702 times.
131702 if(0!=(s=checkEWpn(ri->ewpn,"Angular")))
19605 {
19606 131702 ((weapon*)s)->angular=(value!=0);
19607 131702 ((weapon*)(s))->doAutoRotate(false, true);
19608 131702 }
19609
19610 131702 break;
19611
19612 case EWPNAUTOROTATE:
19613 if(0!=(s=checkEWpn(ri->ewpn,"AutoRotate")))
19614 {
19615 ((weapon*)s)->autorotate=(value!=0);
19616 ((weapon*)(s))->doAutoRotate(false, true);
19617 }
19618
19619 break;
19620
19621 case EWPNBEHIND:
19622
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(0!=(s=checkEWpn(ri->ewpn,"Behind")))
19623 47 ((weapon*)s)->behind=(value!=0);
19624
19625 47 break;
19626
19627 case EWPNDRAWTYPE:
19628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12175 times.
12175 if(0!=(s=checkEWpn(ri->ewpn,"DrawStyle")))
19629 12175 ((weapon*)s)->drawstyle=(value/10000);
19630
19631 12175 break;
19632
19633 case EWPNPOWER:
19634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132679 times.
132679 if(0!=(s=checkEWpn(ri->ewpn,"Damage")))
19635 132679 ((weapon*)s)->power=(value/10000);
19636
19637 132679 break;
19638
19639 case EWPNDEAD:
19640
1/2
✓ Branch 0 taken 23997 times.
✗ Branch 1 not taken.
23997 if(0!=(s=checkEWpn(ri->ewpn,"DeadState")))
19641 {
19642 23997 auto dead = value/10000;
19643 23997 ((weapon*)s)->dead=dead;
19644
2/2
✓ Branch 0 taken 15476 times.
✓ Branch 1 taken 8521 times.
23997 if(dead != 0) ((weapon*)s)->weapon_dying_frame = false;
19645 23997 }
19646
19647 23997 break;
19648
19649 case EWPNID:
19650 if(0!=(s=checkEWpn(ri->ewpn,"ID")))
19651 ((weapon*)s)->id=(value/10000);
19652
19653 break;
19654
19655 case EWPNTILE:
19656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9747 times.
9747 if(0!=(s=checkEWpn(ri->ewpn,"Tile")))
19657 9747 ((weapon*)s)->tile=(value/10000);
19658
19659 9747 break;
19660
19661 case EWPNSCRIPTTILE:
19662 if(0!=(s=checkEWpn(ri->ewpn,"ScriptTile")))
19663 ((weapon*)s)->scripttile=vbound((value/10000),-1, NEWMAXTILES-1);
19664
19665 break;
19666
19667 case EWPNSCRIPTFLIP:
19668 if(0!=(s=checkEWpn(ri->ewpn,"ScriptFlip")))
19669 ((weapon*)s)->scriptflip=vbound((value/10000),-1, 127);
19670
19671 break;
19672
19673 case EWPNCSET:
19674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2072 times.
2072 if(0!=(s=checkEWpn(ri->ewpn,"CSet")))
19675 2072 ((weapon*)s)->cs=(value/10000)&15;
19676
19677 2072 break;
19678
19679 case EWPNFLASHCSET:
19680 if(0!=(s=checkEWpn(ri->ewpn,"FlashCSet")))
19681 (((weapon*)s)->o_cset)|=(value/10000)<<4;
19682
19683 break;
19684
19685 case EWPNFRAMES:
19686
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 if(0!=(s=checkEWpn(ri->ewpn,"NumFrames")))
19687 41 ((weapon*)s)->frames=(value/10000);
19688
19689 41 break;
19690
19691 case EWPNFRAME:
19692 if(0!=(s=checkEWpn(ri->ewpn,"Frame")))
19693 ((weapon*)s)->aframe=(value/10000);
19694
19695 break;
19696
19697 case EWPNASPEED:
19698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 if(0!=(s=checkEWpn(ri->ewpn,"ASpeed")))
19699 41 ((weapon*)s)->o_speed=(value/10000);
19700
19701 41 break;
19702
19703 case EWPNFLASH:
19704
1/2
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
549 if(0!=(s=checkEWpn(ri->ewpn,"Flash")))
19705 549 ((weapon*)s)->flash=(value/10000);
19706
19707 549 break;
19708
19709 case EWPNFLIP:
19710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49622 times.
49622 if(0!=(s=checkEWpn(ri->ewpn,"Flip")))
19711 49622 ((weapon*)s)->flip=(value/10000);
19712
19713 49622 break;
19714
19715 case EWPNROTATION:
19716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1104 times.
1104 if ( get_qr(qr_OLDSPRITEDRAWS) )
19717 {
19718 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
19719 "eweapon->Rotation");
19720 break;
19721 }
19722
1/2
✓ Branch 0 taken 1104 times.
✗ Branch 1 not taken.
1104 if(0!=(s=checkEWpn(ri->ewpn,"Rotation")))
19723 1104 ((weapon*)s)->rotation=(value/10000);
19724
19725 1104 break;
19726
19727 case EWPNEXTEND:
19728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111461 times.
111461 if(0!=(s=checkEWpn(ri->ewpn,"Extend")))
19729 111461 ((weapon*)s)->extend=(value/10000);
19730
19731 111461 break;
19732
19733 case EWPNOTILE:
19734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4552 times.
4552 if(0!=(s=checkEWpn(ri->ewpn,"OriginalTile")))
19735 {
19736 4552 ((weapon*)s)->o_tile=(value/10000);
19737 4552 ((weapon*)s)->ref_o_tile=(value/10000);
19738 4552 }
19739
19740 4552 break;
19741
19742 case EWPNOCSET:
19743 if(0!=(s=checkEWpn(ri->ewpn,"OriginalCSet")))
19744 (((weapon*)s)->o_cset)|=(value/10000)&15;
19745
19746 break;
19747
19748 case EWPNHXOFS:
19749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138269 times.
138269 if(0!=(s=checkEWpn(ri->ewpn,"HitXOffset")))
19750 138269 (((weapon*)s)->hxofs)=(value/10000);
19751
19752 138269 break;
19753
19754 case EWPNHYOFS:
19755
1/2
✓ Branch 0 taken 137776 times.
✗ Branch 1 not taken.
137776 if(0!=(s=checkEWpn(ri->ewpn,"HitYOffset")))
19756 137776 (((weapon*)s)->hyofs)=(value/10000);
19757
19758 137776 break;
19759
19760 case EWPNXOFS:
19761
2/2
✓ Branch 0 taken 35366 times.
✓ Branch 1 taken 4 times.
35370 if(0!=(s=checkEWpn(ri->ewpn,"DrawXOffset")))
19762 35366 (((weapon*)s)->xofs)=(zfix)(value/10000);
19763
19764 35370 break;
19765
19766 case EWPNYOFS:
19767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38448 times.
38448 if(0!=(s=checkEWpn(ri->ewpn,"DrawYOffset")))
19768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38448 times.
38448 (((weapon*)s)->yofs)=(zfix)(value/10000)+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
19769
19770 38448 break;
19771 case EWPNTOTALDYOFFS:
19772 break; //READ-ONLY
19773
19774 case EWPNSHADOWXOFS:
19775 if(0!=(s=checkEWpn(ri->ewpn,"ShadowXOffset")))
19776 (((weapon*)s)->shadowxofs)=(zfix)(value/10000);
19777
19778 break;
19779
19780 case EWPNSHADOWYOFS:
19781 if(0!=(s=checkEWpn(ri->ewpn,"ShadowYOffset")))
19782 (((weapon*)s)->shadowyofs)=(zfix)(value/10000);
19783
19784 break;
19785
19786 case EWPNZOFS:
19787 if(0!=(s=checkEWpn(ri->ewpn,"DrawZOffset")))
19788 (((weapon*)s)->zofs)=(zfix)(value/10000);
19789
19790 break;
19791
19792 case EWPNHXSZ:
19793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 234661 times.
234661 if(0!=(s=checkEWpn(ri->ewpn,"HitWidth")))
19794 234661 (((weapon*)s)->hit_width)=(value/10000);
19795
19796 234661 break;
19797
19798 case EWPNHYSZ:
19799
1/2
✓ Branch 0 taken 234074 times.
✗ Branch 1 not taken.
234074 if(0!=(s=checkEWpn(ri->ewpn,"HitHeight")))
19800 234074 (((weapon*)s)->hit_height)=(value/10000);
19801
19802 234074 break;
19803
19804 case EWPNHZSZ:
19805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(0!=(s=checkEWpn(ri->ewpn,"HitZHeight")))
19806 44 (((weapon*)s)->hzsz)=(value/10000);
19807
19808 44 break;
19809
19810 case EWPNTXSZ:
19811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111461 times.
111461 if(0!=(s=checkEWpn(ri->ewpn,"TileWidth")))
19812 111461 (((weapon*)s)->txsz)=vbound((value/10000),1,20);
19813
19814 111461 break;
19815
19816 case EWPNTYSZ:
19817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111461 times.
111461 if(0!=(s=checkEWpn(ri->ewpn,"TileHeight")))
19818 111461 (((weapon*)s)->tysz)=vbound((value/10000),1,20);
19819
19820 111461 break;
19821
19822 case EWPNMISCD:
19823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 910117 times.
910117 if(0!=(s=checkEWpn(ri->ewpn,"Misc")))
19824 {
19825 910117 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
19826 910117 (((weapon*)(s))->miscellaneous[a])=value;
19827 910117 }
19828
19829 910117 break;
19830
19831 case EWPNCOLLDET:
19832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20016 times.
20016 if(0!=(s=checkEWpn(ri->ewpn,"CollDetection")))
19833 20016 (((weapon*)(s))->scriptcoldet)=value/10000;
19834
19835 20016 break;
19836
19837 case EWPNENGINEANIMATE:
19838 if(0!=(s=checkEWpn(ri->ewpn,"Animation")))
19839 (((weapon*)(s))->do_animation)=(value ? 1 : 0);
19840
19841 break;
19842
19843
19844 case EWPNPARENTUID:
19845 if(0!=(s=checkEWpn(ri->ewpn, "ParentUID")))
19846 (((weapon*)(s))->parent_script_UID) = value; //literal, not *10000
19847 break;
19848
19849 case EWPNPARENT:
19850 if(0!=(s=checkEWpn(ri->ewpn, "Parent")))
19851 (((weapon*)(s))->parentid)= ( (get_qr(qr_OLDEWPNPARENT)) ? value / 10000 : value );
19852
19853 break;
19854
19855 case EWPNSCRIPT:
19856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1275 times.
1275 if(0!=(s=checkEWpn(ri->ewpn,"Script")))
19857 {
19858 1275 FFScript::deallocateAllScriptOwned(ScriptType::Ewpn, ri->ewpn);
19859 1275 (((weapon*)(s))->weaponscript)=vbound(value/10000,0,NUMSCRIPTWEAPONS-1);
19860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1275 times.
1275 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
19861 {
19862
2/2
✓ Branch 0 taken 10200 times.
✓ Branch 1 taken 1275 times.
11475 for(int32_t q=0; q<8; q++)
19863 10200 (((weapon*)(s))->weap_initd[q]) = 0;
19864 1275 }
19865 1275 }
19866 1275 break;
19867
19868 case EWPNINITD:
19869 {
19870 4214 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
19871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4214 times.
4214 if(0!=(s=checkEWpn(ri->ewpn,"InitD[]")))
19872 {
19873 4214 (((weapon*)(s))->weap_initd[a])=value;
19874 4214 }
19875 4214 break;
19876 }
19877 case EWPNFALLCLK:
19878 if(0!=(s=checkEWpn(ri->ewpn,"Falling")))
19879 {
19880 if(((weapon*)(s))->fallclk != 0 && value == 0)
19881 {
19882 ((weapon*)(s))->cs = ((weapon*)(s))->old_cset;
19883 ((weapon*)(s))->tile = ((weapon*)(s))->o_tile;
19884 }
19885 else if(((weapon*)(s))->fallclk == 0 && value != 0) ((weapon*)(s))->old_cset = ((weapon*)(s))->cs;
19886 ((weapon*)(s))->fallclk = vbound(value/10000,0,70);
19887 }
19888 break;
19889 case EWPNFALLCMB:
19890 if(0!=(s=checkEWpn(ri->ewpn,"FallCombo")))
19891 {
19892 ((weapon*)(s))->fallCombo = vbound(value/10000,0,MAXCOMBOS-1);
19893 }
19894 break;
19895 case EWPNDROWNCLK:
19896 if(0!=(s=checkEWpn(ri->ewpn,"Drowning")))
19897 {
19898 if(((weapon*)(s))->drownclk != 0 && value == 0)
19899 {
19900 ((weapon*)(s))->cs = ((weapon*)(s))->old_cset;
19901 ((weapon*)(s))->tile = ((weapon*)(s))->o_tile;
19902 }
19903 else if(((weapon*)(s))->drownclk == 0 && value != 0) ((weapon*)(s))->old_cset = ((weapon*)(s))->cs;
19904 ((weapon*)(s))->drownclk = vbound(value/10000,0,70);
19905 }
19906 break;
19907 case EWPNDROWNCMB:
19908 if(0!=(s=checkEWpn(ri->ewpn,"DrownCombo")))
19909 {
19910 ((weapon*)(s))->drownCombo = vbound(value/10000,0,MAXCOMBOS-1);
19911 }
19912 break;
19913 case EWPNFAKEZ:
19914 if(0!=(s=checkEWpn(ri->ewpn,"FakeZ")))
19915 {
19916 ((weapon*)s)->fakez=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
19917 if(((weapon*)s)->fakez < 0) ((weapon*)s)->fakez = 0_zf;
19918 }
19919
19920 break;
19921
19922 case EWPNMOVEFLAGS:
19923 {
19924 if(0!=(s=checkEWpn(ri->ewpn,"MoveFlags[]")))
19925 {
19926 int32_t indx = ri->d[rINDEX]/10000;
19927 if(BC::checkBounds(indx, 0, 10, "eweapon->MoveFlags[]") == SH::_NoError)
19928 {
19929 //All bits, in order, of a single byte; just use bitwise
19930 int32_t bit = 1<<indx;
19931 if(value)
19932 ((weapon*)(s))->moveflags |= bit;
19933 else
19934 ((weapon*)(s))->moveflags &= ~bit;
19935 }
19936 }
19937 break;
19938 }
19939 case EWPNFLAGS:
19940 {
19941 if(0!=(s=checkEWpn(ri->ewpn,"Flags[]")))
19942 {
19943 int32_t indx = ri->d[rINDEX]/10000;
19944 if(BC::checkBounds(indx, 0, WFLAG_MAX, "eweapon->Flags[]") == SH::_NoError)
19945 {
19946 //All bits, in order, of a single byte; just use bitwise
19947 int32_t bit = 1<<indx;
19948 if(value)
19949 ((weapon*)(s))->misc_wflags |= bit;
19950 else
19951 ((weapon*)(s))->misc_wflags &= ~bit;
19952 }
19953 }
19954 break;
19955 }
19956
19957 case EWPNGLOWRAD:
19958 if(0!=(s=checkEWpn(ri->ewpn,"LightRadius")))
19959 {
19960 ((weapon*)(s))->glowRad = vbound(value/10000,0,255);
19961 }
19962 break;
19963 case EWPNGLOWSHP:
19964 if(0!=(s=checkEWpn(ri->ewpn,"LightShape")))
19965 {
19966 ((weapon*)(s))->glowShape = vbound(value/10000,0,255);
19967 }
19968 break;
19969
19970 case EWPNUNBL:
19971 if(0!=(s=checkEWpn(ri->ewpn,"Unblockable")))
19972 {
19973 ((weapon*)(s))->unblockable = (value/10000)&WPNUNB_ALL;
19974 }
19975 break;
19976
19977 case EWPNSHADOWSPR:
19978 if(0!=(s=checkEWpn(ri->ewpn,"ShadowSprite")))
19979 {
19980 ((weapon*)(s))->spr_shadow = vbound(value/10000, 0, 255);
19981 }
19982 break;
19983 case EWSWHOOKED:
19984 break; //read-only
19985 case EWPNTIMEOUT:
19986 if(0!=(s=checkEWpn(ri->ewpn,"Timeout")))
19987 {
19988 ((weapon*)(s))->weap_timeout = vbound(value/10000,0,214748);
19989 }
19990 break;case EWPNDEATHITEM:
19991 if(0!=(s=checkEWpn(ri->ewpn,"DeathItem")))
19992 {
19993 ((weapon*)(s))->death_spawnitem = vbound(value/10000,-1,MAXITEMS-1);
19994 }
19995 break;
19996 case EWPNDEATHDROPSET:
19997 if(0!=(s=checkEWpn(ri->ewpn,"DeathDropset")))
19998 {
19999 ((weapon*)(s))->death_spawndropset = vbound(value/10000,-1,MAXITEMDROPSETS-1);
20000 }
20001 break;
20002 case EWPNDEATHIPICKUP:
20003 if(0!=(s=checkEWpn(ri->ewpn,"DeathItemPFlags")))
20004 {
20005 ((weapon*)(s))->death_item_pflags = value/10000;
20006 }
20007 break;
20008 case EWPNDEATHSPRITE:
20009 if(0!=(s=checkEWpn(ri->ewpn,"DeathSprite")))
20010 {
20011 ((weapon*)(s))->death_sprite = vbound(value/10000,-255,MAXWPNS-1);
20012 }
20013 break;
20014 case EWPNDEATHSFX:
20015 if(0!=(s=checkEWpn(ri->ewpn,"DeathSFX")))
20016 {
20017 ((weapon*)(s))->death_sfx = vbound(value/10000,0,WAV_COUNT);
20018 }
20019 break;
20020 case EWPNLIFTLEVEL:
20021 if(0!=(s=checkEWpn(ri->ewpn,"LiftLevel")))
20022 {
20023 ((weapon*)(s))->lift_level = vbound(value/10000,0,255);
20024 }
20025 break;
20026 case EWPNLIFTTIME:
20027 if(0!=(s=checkEWpn(ri->ewpn,"LiftTime")))
20028 {
20029 ((weapon*)(s))->lift_time = vbound(value/10000,0,255);
20030 }
20031 break;
20032 case EWPNLIFTHEIGHT:
20033 if(0!=(s=checkEWpn(ri->ewpn,"LiftHeight")))
20034 {
20035 ((weapon*)(s))->lift_height = zslongToFix(value);
20036 }
20037 break;
20038
20039 ///----------------------------------------------------------------------------------------------------//
20040 //NPC Variables
20041
20042 //Fixs are all a bit different
20043 case NPCX:
20044 {
20045
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1038284 times.
1038288 if(GuyH::loadNPC(ri->guyref, "npc->X") == SH::_NoError)
20046 {
20047
2/2
✓ Branch 0 taken 97206 times.
✓ Branch 1 taken 941078 times.
1038284 GuyH::getNPC()->x = get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
20048
20049
1/2
✓ Branch 0 taken 1038284 times.
✗ Branch 1 not taken.
1038284 if(GuyH::hasHero())
20050 Hero.setXfix(get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
20051 1038284 }
20052 }
20053 1038288 break;
20054
20055 case NPCSCALE:
20056 {
20057 if ( get_qr(qr_OLDSPRITEDRAWS) )
20058 {
20059 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
20060 "npc->Scale");
20061 break;
20062 }
20063 if(GuyH::loadNPC(ri->guyref, "npc->Scale") == SH::_NoError)
20064 {
20065 GuyH::getNPC()->scale = (value / 100.0);
20066 }
20067 }
20068 break;
20069
20070 case NPCIMMORTAL:
20071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(GuyH::loadNPC(ri->guyref, "npc->Immortal") == SH::_NoError)
20072 {
20073 3 GuyH::getNPC()->immortal = (value ? true : false);
20074 3 }
20075 3 break;
20076
20077 case NPCNOSLIDE:
20078 if(GuyH::loadNPC(ri->guyref, "npc->NoSlide") == SH::_NoError)
20079 {
20080 if(value)
20081 {
20082 GuyH::getNPC()->knockbackflags |= FLAG_NOSLIDE;
20083 }
20084 else
20085 {
20086 GuyH::getNPC()->knockbackflags &= ~FLAG_NOSLIDE;
20087 }
20088 }
20089 break;
20090
20091 case NPCNOSCRIPTKB:
20092 if(GuyH::loadNPC(ri->guyref, "npc->NoScriptKnockback") == SH::_NoError)
20093 {
20094 if(value)
20095 {
20096 GuyH::getNPC()->knockbackflags |= FLAG_NOSCRIPTKNOCKBACK;
20097 }
20098 else
20099 {
20100 GuyH::getNPC()->knockbackflags &= ~FLAG_NOSCRIPTKNOCKBACK;
20101 }
20102 }
20103 break;
20104
20105 case NPCKNOCKBACKSPEED:
20106 if(GuyH::loadNPC(ri->guyref, "npc->NoKnockback") == SH::_NoError)
20107 {
20108 GuyH::getNPC()->knockbackSpeed = vbound(value/10000, 0, 255);
20109 }
20110 break;
20111
20112 case SPRITEMAXNPC:
20113 {
20114 //No bounds check, as this is a universal function and works from NULL pointers!
20115 guys.setMax(vbound((value/10000),1,MAX_NPC_SPRITES));
20116 break;
20117 }
20118
20119 case NPCY:
20120 {
20121
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1042635 times.
1042699 if(GuyH::loadNPC(ri->guyref, "npc->Y") == SH::_NoError)
20122 {
20123 1042635 zfix oldy = GuyH::getNPC()->y;
20124
2/2
✓ Branch 0 taken 97206 times.
✓ Branch 1 taken 945429 times.
1042635 GuyH::getNPC()->y = get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
20125
2/2
✓ Branch 0 taken 97206 times.
✓ Branch 1 taken 945429 times.
1042635 GuyH::getNPC()->floor_y += ((get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000)) - oldy);
20126
20127
1/2
✓ Branch 0 taken 1042635 times.
✗ Branch 1 not taken.
1042635 if(GuyH::hasHero())
20128 Hero.setYfix(get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
20129 1042635 }
20130 }
20131 1042699 break;
20132
20133 case NPCZ:
20134 {
20135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 970520 times.
970520 if(GuyH::loadNPC(ri->guyref, "npc->Z") == SH::_NoError)
20136 {
20137
2/2
✓ Branch 0 taken 1114 times.
✓ Branch 1 taken 969406 times.
970520 if(!never_in_air(GuyH::getNPC()->id))
20138 {
20139
1/2
✓ Branch 0 taken 969406 times.
✗ Branch 1 not taken.
969406 if(value < 0)
20140 GuyH::getNPC()->z = 0_zf;
20141 else
20142
2/2
✓ Branch 0 taken 97013 times.
✓ Branch 1 taken 872393 times.
969406 GuyH::getNPC()->z = get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
20143
20144
1/2
✓ Branch 0 taken 969406 times.
✗ Branch 1 not taken.
969406 if(GuyH::hasHero())
20145 Hero.setZfix(get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
20146 969406 }
20147 970520 }
20148 }
20149 970520 break;
20150
20151 case NPCJUMP:
20152 {
20153
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 973311 times.
973735 if(GuyH::loadNPC(ri->guyref, "npc->Jump") == SH::_NoError)
20154 {
20155
2/2
✓ Branch 0 taken 56049 times.
✓ Branch 1 taken 917262 times.
973311 if(canfall(GuyH::getNPC()->id))
20156 917262 GuyH::getNPC()->fall =zslongToFix(value)*-100;
20157
20158
1/2
✓ Branch 0 taken 973311 times.
✗ Branch 1 not taken.
973311 if(GuyH::hasHero())
20159 Hero.setFall(zslongToFix(value)*-100);
20160 973311 }
20161 }
20162 973735 break;
20163
20164 case NPCFAKEJUMP:
20165 {
20166 if(GuyH::loadNPC(ri->guyref, "npc->FakeJump") == SH::_NoError)
20167 {
20168 if(canfall(GuyH::getNPC()->id))
20169 GuyH::getNPC()->fakefall =zslongToFix(value)*-100;
20170
20171 if(GuyH::hasHero())
20172 Hero.setFakeFall(zslongToFix(value)*-100);
20173 }
20174 }
20175 break;
20176
20177 case NPCSTEP:
20178 {
20179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 if(GuyH::loadNPC(ri->guyref, "npc->Step") == SH::_NoError)
20180 {
20181
2/4
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 71 times.
✗ Branch 3 not taken.
71 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
20182 {
20183 71 GuyH::getNPC()->step = zslongToFix(value / 100);
20184 71 }
20185 else
20186 {
20187 //old, buggy code replication, round two: Go! -Z
20188 //zfix val = zslongToFix(value);
20189 //val.doFloor();
20190 //GuyH::getNPC()->step = ((val / 100.0).getFloat());
20191
20192 //old, buggy code replication, round THREE: Go! -Z
20193 GuyH::getNPC()->step = ((value/10000)/100.0);
20194 }
20195 71 }
20196 }
20197 71 break;
20198
20199 case NPCGRAVITY:
20200 {
20201 if(GuyH::loadNPC(ri->guyref, "npc->Gravity") == SH::_NoError)
20202 {
20203 if(value)
20204 GuyH::getNPC()->moveflags |= FLAG_OBEYS_GRAV;
20205 else
20206 GuyH::getNPC()->moveflags &= ~FLAG_OBEYS_GRAV;
20207 }
20208 }
20209 break;
20210
20211 case NPCXOFS:
20212 {
20213
1/2
✓ Branch 0 taken 21269 times.
✗ Branch 1 not taken.
21269 if(GuyH::loadNPC(ri->guyref, "npc->DrawXOffset") == SH::_NoError)
20214 21269 GuyH::getNPC()->xofs = zfix(value / 10000);
20215 }
20216 21269 break;
20217
20218 case NPCYOFS:
20219 {
20220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28037 times.
28037 if(GuyH::loadNPC(ri->guyref, "npc->DrawYOffset") == SH::_NoError)
20221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28037 times.
28037 GuyH::getNPC()->yofs = zfix(value / 10000) + (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
20222 }
20223 28037 break;
20224
20225 case NPCSHADOWXOFS:
20226 {
20227 if(GuyH::loadNPC(ri->guyref, "npc->ShadowXOffset") == SH::_NoError)
20228 GuyH::getNPC()->shadowxofs = zfix(value / 10000);
20229 }
20230 break;
20231
20232 case NPCSHADOWYOFS:
20233 {
20234 if(GuyH::loadNPC(ri->guyref, "npc->ShadowYOffset") == SH::_NoError)
20235 GuyH::getNPC()->shadowyofs = zfix(value / 10000);
20236 }
20237 break;
20238
20239 case NPCTOTALDYOFFS:
20240 break; //READ-ONLY
20241
20242 case NPCROTATION:
20243 {
20244 if ( get_qr(qr_OLDSPRITEDRAWS) )
20245 {
20246 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
20247 "npc->Rotation");
20248 break;
20249 }
20250 if(GuyH::loadNPC(ri->guyref, "npc->Rotation") == SH::_NoError)
20251 GuyH::getNPC()->rotation = (value / 10000);
20252 }
20253 break;
20254
20255 case NPCZOFS:
20256 {
20257 if(GuyH::loadNPC(ri->guyref, "npc->DrawZOffset") == SH::_NoError)
20258 GuyH::getNPC()->zofs = zfix(value / 10000);
20259 }
20260 break;
20261
20262 #define SET_NPC_VAR_INT(member, str) \
20263 { \
20264 if(GuyH::loadNPC(ri->guyref, str) == SH::_NoError) \
20265 GuyH::getNPC()->member = value / 10000; \
20266 }
20267
20268
20269 case NPCISCORE:
20270 if(GuyH::loadNPC(ri->guyref, "npc->isCore") == SH::_NoError)
20271 GuyH::getNPC()->isCore = ( (value / 10000) ? true : false );
20272 break;
20273
20274
20275 case NPCDIR:
20276
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1046411 times.
1046835 SET_NPC_VAR_INT(dir, "npc->Dir") break;
20277
20278 case NPCHITDIR:
20279 if(GuyH::loadNPC(ri->guyref, "npc->HitDir") != SH::_NoError)
20280 (GuyH::getNPC()->hitdir) = vbound(value/10000, 0, 3);
20281
20282 break;
20283
20284 case NPCSLIDECLK:
20285 if(GuyH::loadNPC(ri->guyref, "npc->SlideClock") != SH::_NoError)
20286 GuyH::getNPC()->sclk = value/10000;//vbound(value/10000,0,255);
20287
20288 break;
20289
20290 case NPCFADING:
20291 if(GuyH::loadNPC(ri->guyref, "npc->Fading") != SH::_NoError)
20292 (GuyH::getNPC()->fading) = vbound(value/10000,0,4);
20293
20294 break;
20295
20296 case NPCHALTCLK:
20297 if(GuyH::loadNPC(ri->guyref, "npc->Halt") != SH::_NoError)
20298 (GuyH::getNPC()->clk2) = vbound(value/10000,0,214748);
20299
20300 break;
20301
20302 case NPCFRAME:
20303 if(GuyH::loadNPC(ri->guyref, "npc->Frame") != SH::_NoError)
20304 (GuyH::getNPC()->clk2) = vbound(value/10000,0,214748);
20305
20306 break;
20307
20308 case NPCMOVESTATUS:
20309 if(GuyH::loadNPC(ri->guyref, "npc->MoveStatus") != SH::_NoError)
20310 (GuyH::getNPC()->movestatus) = vbound(value/10000,0,3);
20311
20312 break;
20313
20314 case NPCRATE:
20315 SET_NPC_VAR_INT(rate, "npc->Rate") break;
20316
20317 case NPCHOMING:
20318 SET_NPC_VAR_INT(homing, "npc->Homing") break;
20319
20320 case NPCFRAMERATE:
20321 SET_NPC_VAR_INT(frate, "npc->ASpeed") break;
20322
20323 case NPCHALTRATE:
20324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 SET_NPC_VAR_INT(hrate, "npc->HaltRate") break;
20325
20326 case NPCRANDOM:
20327 SET_NPC_VAR_INT(rate, "npc->Random") break;
20328
20329 case NPCDRAWTYPE:
20330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4414 times.
4414 SET_NPC_VAR_INT(drawstyle, "npc->DrawStyle") break;
20331
20332 case NPCHP:
20333
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 1033702 times.
1034127 SET_NPC_VAR_INT(hp, "npc->HP") break;
20334
20335 case NPCORIGINALHP:
20336 SET_NPC_VAR_INT(starting_hp, "npc->OriginalHP") break;
20337
20338 //case NPCID: SET_NPC_VAR_INT(id, "npc->ID") break; ~Disallowed
20339 case NPCDP:
20340
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 784 times.
788 SET_NPC_VAR_INT(dp, "npc->Damage") break;
20341
20342 case NPCTYPE:
20343 {
20344 SET_NPC_VAR_INT(family, "npc->Type") break;
20345 }
20346
20347 case NPCWDP:
20348
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 317 times.
321 SET_NPC_VAR_INT(wdp, "npc->WeaponDamage") break;
20349
20350 case NPCITEMSET:
20351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 SET_NPC_VAR_INT(item_set, "npc->ItemSet") break;
20352
20353 case NPCBOSSPAL:
20354 SET_NPC_VAR_INT(bosspal, "npc->BossPal") break;
20355
20356 case NPCBGSFX:
20357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(GuyH::loadNPC(ri->guyref, "npc->SFX") == SH::_NoError)
20358 {
20359 13 enemy *en=GuyH::getNPC();
20360 13 int32_t newSFX = value / 10000;
20361
20362 // Stop the old sound and start the new one
20363
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if(en->bgsfx != newSFX)
20364 {
20365 2 en->stop_bgsfx(GuyH::getNPCIndex(ri->guyref));
20366 2 cont_sfx(newSFX);
20367 2 en->bgsfx = newSFX;
20368 2 }
20369 13 }
20370 13 break;
20371
20372
20373 case NPCEXTEND:
20374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77612 times.
77612 SET_NPC_VAR_INT(extend, "npc->Extend") break;
20375
20376 case NPCHXOFS:
20377
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 749 times.
1181 SET_NPC_VAR_INT(hxofs, "npc->HitXOffset") break;
20378
20379 case NPCHYOFS:
20380
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 3751 times.
4183 SET_NPC_VAR_INT(hyofs, "npc->HitYOffset") break;
20381
20382 case NPCHXSZ:
20383
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 6636 times.
7068 SET_NPC_VAR_INT(hit_width, "npc->HitWidth") break;
20384
20385 case NPCHYSZ:
20386
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 6636 times.
7068 SET_NPC_VAR_INT(hit_height, "npc->HitHeight") break;
20387
20388 case NPCHZSZ:
20389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 SET_NPC_VAR_INT(hzsz, "npc->HitZHeight") break;
20390
20391 case NPCCOLLDET:
20392
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 28755 times.
28759 SET_NPC_VAR_INT(scriptcoldet, "npc->CollDetection") break;
20393
20394 case NPCENGINEANIMATE:
20395 SET_NPC_VAR_INT(do_animation, "npc->Animation") break;
20396
20397 case NPCSTUN:
20398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1094 times.
1094 SET_NPC_VAR_INT(stunclk, "npc->Stun") break;
20399
20400 case NPCHUNGER:
20401 SET_NPC_VAR_INT(grumble, "npc->Hunger") break;
20402
20403 case NPCWEAPSPRITE:
20404 SET_NPC_VAR_INT(wpnsprite, "npc->WeaponSprite") break;
20405
20406 case NPCCSET:
20407 {
20408
2/2
✓ Branch 0 taken 1020071 times.
✓ Branch 1 taken 435 times.
1020506 if(GuyH::loadNPC(ri->guyref, "npc->CSet") == SH::_NoError)
20409 {
20410 1020071 GuyH::getNPC()->cs = (value / 10000) & 0xF;
20411
1/2
✓ Branch 0 taken 1020071 times.
✗ Branch 1 not taken.
1020071 if(GuyH::getNPC()->family == eeLEV) GuyH::getNPC()->dcset = (value / 10000) & 0xF;
20412 1020071 }
20413 }
20414 1020506 break;
20415
20416 //Bounds on value
20417 case NPCTXSZ:
20418 {
20419 10539 int32_t height = value / 10000;
20420
20421
3/4
✓ Branch 0 taken 10103 times.
✓ Branch 1 taken 436 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10103 times.
10539 if(GuyH::loadNPC(ri->guyref, "npc->TileWidth") == SH::_NoError &&
20422 10103 BC::checkBounds(height, 0, 20, "npc->TileWidth") == SH::_NoError)
20423 10103 GuyH::getNPC()->txsz = height;
20424 }
20425 10539 break;
20426
20427 case NPCTYSZ:
20428 {
20429 10539 int32_t width = value / 10000;
20430
20431
3/4
✓ Branch 0 taken 10103 times.
✓ Branch 1 taken 436 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10103 times.
10539 if(GuyH::loadNPC(ri->guyref, "npc->TileHeight") == SH::_NoError &&
20432 10103 BC::checkBounds(width, 0, 20, "npc->TileHeight") == SH::_NoError)
20433 10103 GuyH::getNPC()->tysz = width;
20434 }
20435 10539 break;
20436
20437 case NPCOTILE:
20438 {
20439 8696 int32_t tile = value / 10000;
20440
20441
3/4
✓ Branch 0 taken 8689 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8689 times.
8696 if(GuyH::loadNPC(ri->guyref, "npc->OriginalTile") == SH::_NoError &&
20442 8689 BC::checkTile(tile, "npc->OriginalTile") == SH::_NoError)
20443 8689 GuyH::getNPC()->o_tile = tile;
20444 }
20445 8696 break;
20446
20447 case NPCTILE:
20448 {
20449 4912 int32_t tile = value / 10000;
20450
20451
2/4
✓ Branch 0 taken 4912 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4912 times.
4912 if(GuyH::loadNPC(ri->guyref, "npc->Tile") == SH::_NoError &&
20452 4912 BC::checkTile(tile, "npc->Tile") == SH::_NoError)
20453 4912 GuyH::getNPC()->tile = tile;
20454 }
20455 4912 break;
20456
20457 case NPCSCRIPTTILE:
20458 {
20459 if(GuyH::loadNPC(ri->guyref, "npc->ScriptTile") == SH::_NoError)
20460 GuyH::getNPC()->scripttile = vbound((value/10000),-1, NEWMAXTILES-1);
20461 }
20462 break;
20463
20464 case NPCSCRIPTFLIP:
20465 {
20466 if(GuyH::loadNPC(ri->guyref, "npc->ScriptFlip") == SH::_NoError )
20467 GuyH::getNPC()->scriptflip = vbound(value/10000, -1, 127);
20468 }
20469 break;
20470
20471 case NPCWEAPON:
20472 {
20473 int32_t weapon = value / 10000;
20474
20475 if(GuyH::loadNPC(ri->guyref, "npc->Weapon") == SH::_NoError &&
20476 BC::checkBounds(weapon, 0, MAXWPNS-1, "npc->Weapon") == SH::_NoError)
20477 {
20478 GuyH::getNPC()->wpn = weapon;
20479
20480 //al_trace("Correct weapon sprite is: %d /n", FFCore.GetDefaultWeaponSprite(weapon));
20481 if ( get_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE) ) //this should probably just be an extra_rule
20482 {
20483 GuyH::getNPC()->wpnsprite = FFCore.GetDefaultWeaponSprite(weapon);
20484 }
20485 //else GuyH::getNPC()->wpnsprite = FFCore.GetDefaultWeaponSprite(weapon); //just to test that this works.
20486 }
20487 }
20488 break;
20489
20490 //Indexed
20491 case NPCDEFENSED:
20492 {
20493 545362 int32_t a = ri->d[rINDEX] / 10000;
20494
20495
2/4
✓ Branch 0 taken 545362 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 545362 times.
545362 if(GuyH::loadNPC(ri->guyref, "npc->Defense") == SH::_NoError &&
20496 545362 BC::checkBounds(a, 0, (edefLAST255), "npc->Defense") == SH::_NoError)
20497 {
20498
4/4
✓ Branch 0 taken 545278 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 521697 times.
✓ Branch 3 taken 23581 times.
545362 if ( ( get_qr(qr_250WRITEEDEFSCRIPT) ) && a == edefSCRIPT )
20499 {
20500
2/2
✓ Branch 0 taken 235810 times.
✓ Branch 1 taken 23581 times.
259391 for ( int32_t sd = edefSCRIPT01; sd <= edefSCRIPT10; sd++ )
20501 {
20502 235810 GuyH::getNPC()->defense[sd] = vbound((value / 10000),0,255);
20503 235810 }
20504 23581 }
20505 //no else here, is intentional as a fallthrough. -Z
20506 545362 GuyH::getNPC()->defense[a] = vbound((value / 10000),0,255);
20507 545362 }
20508 }
20509 545362 break;
20510
20511 case NPCPARENTUID:
20512 if(GuyH::loadNPC(ri->guyref, "npc->ParentUID") == SH::_NoError)
20513 {
20514 GuyH::getNPC()->parent_script_UID = value; //literal, not *10000
20515 }
20516 break;
20517
20518 case NPCHITBY:
20519 {
20520 int32_t indx = ri->d[rINDEX] / 10000;
20521
20522 if(GuyH::loadNPC(ri->guyref, "npc->HitBy[]") == SH::_NoError)
20523 {
20524 switch(indx)
20525 {
20526 //screen index objects
20527 case 0:
20528 case 1:
20529 case 2:
20530 case 3:
20531 case 8:
20532 case 9:
20533 case 10:
20534 case 11:
20535 case 12:
20536 case 16:
20537 {
20538 GuyH::getNPC()->hitby[indx] = vbound((value / 10000),0,255); //Once again, why did I vbound this, and why did I allow it to be written? UIDs are LONGs, with a starting value of 0.0001. -Z
20539 break;
20540 }
20541 //UIDs
20542 case 4:
20543 case 5:
20544 case 6:
20545 case 7:
20546 case 13:
20547 case 14:
20548 case 15:
20549 {
20550 GuyH::getNPC()->hitby[indx] = value; //Once again, why did I vbound this, and why did I allow it to be written? UIDs are LONGs, with a starting value of 0.0001. -Z
20551 break;
20552 }
20553 default: al_trace("Invalid index used with npc->hitBy[%d]. /n", indx); break;
20554 }
20555 }
20556 break;
20557 }
20558
20559 //2.future compat. -Z
20560
20561
20562 case NPCSCRDEFENSED:
20563 {
20564 int32_t a = ri->d[rINDEX] / 10000;
20565
20566 if(GuyH::loadNPC(ri->guyref, "npc->ScriptDefense") == SH::_NoError &&
20567 BC::checkBounds(a, 0, edefSCRIPTDEFS_MAX, "npc->ScriptDefense") == SH::_NoError)
20568 GuyH::getNPC()->defense[a+edefSCRIPT01] = value / 10000;
20569 }
20570 break;
20571
20572 case NPCMISCD:
20573 {
20574 2614735 int32_t a = ri->d[rINDEX] / 10000;
20575
20576
3/4
✓ Branch 0 taken 2614696 times.
✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2614696 times.
2614735 if(GuyH::loadNPC(ri->guyref, "npc->Misc") == SH::_NoError &&
20577 2614696 BC::checkMisc32(a, "npc->Misc") == SH::_NoError)
20578 2614696 GuyH::getNPC()->miscellaneous[a] = value;
20579
20580 }
20581
20582 2614735 break;
20583
20584 case NPCINITD:
20585 {
20586 int32_t a = ri->d[rINDEX] / 10000;
20587
20588 if(GuyH::loadNPC(ri->guyref, "npc->InitD[]") == SH::_NoError)
20589 {
20590 //enemy *e = (enemy*)guys.spr(ri->guyref);
20591 //e->initD[a] = value;
20592 GuyH::getNPC()->initD[a] = value;
20593 }
20594 }
20595 break;
20596
20597 case NPCSCRIPT:
20598 {
20599 if(GuyH::loadNPC(ri->guyref, "npc->Script") == SH::_NoError)
20600 {
20601 FFScript::deallocateAllScriptOwned(ScriptType::NPC, ri->guyref);
20602 //enemy *e = (enemy*)guys.spr(ri->guyref);
20603 //e->initD[a] = value;
20604 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
20605 {
20606 for(int32_t q=0; q<8; q++)
20607 GuyH::getNPC()->initD[q] = 0;
20608 }
20609 GuyH::getNPC()->script = vbound((value/10000), 0, NUMSCRIPTGUYS-1);
20610 }
20611 }
20612 break;
20613
20614 //npc->Attributes[] setter -Z
20615 case NPCDD:
20616 {
20617 int32_t a = ri->d[rINDEX] / 10000;
20618
20619 if(GuyH::loadNPC(ri->guyref, "npc->Attributes") == SH::_NoError &&
20620 BC::checkBounds(a, 0, 31, "npc->Attributes") == SH::_NoError)
20621
20622 switch(a)
20623 {
20624 case 0: GuyH::getNPC()->dmisc1 = value / 10000; break;
20625 case 1: GuyH::getNPC()->dmisc2 = value / 10000; break;
20626 case 2: GuyH::getNPC()->dmisc3 = value / 10000; break;
20627 case 3: GuyH::getNPC()->dmisc4 = value / 10000; break;
20628 case 4: GuyH::getNPC()->dmisc5 = value / 10000; break;
20629 case 5: GuyH::getNPC()->dmisc6 = value / 10000; break;
20630 case 6: GuyH::getNPC()->dmisc7 = value / 10000; break;
20631 case 7: GuyH::getNPC()->dmisc8 = value / 10000; break;
20632 case 8: GuyH::getNPC()->dmisc9 = value / 10000; break;
20633 case 9: GuyH::getNPC()->dmisc10 = value / 10000; break;
20634 case 10: GuyH::getNPC()->dmisc11 = value / 10000; break;
20635 case 11: GuyH::getNPC()->dmisc12 = value / 10000; break;
20636 case 12: GuyH::getNPC()->dmisc13 = value / 10000; break;
20637 case 13: GuyH::getNPC()->dmisc14 = value / 10000; break;
20638 case 14: GuyH::getNPC()->dmisc15 = value / 10000; break;
20639 case 15: GuyH::getNPC()->dmisc16 = value / 10000; break;
20640 case 16: GuyH::getNPC()->dmisc17 = value / 10000; break;
20641 case 17: GuyH::getNPC()->dmisc18 = value / 10000; break;
20642 case 18: GuyH::getNPC()->dmisc19 = value / 10000; break;
20643 case 19: GuyH::getNPC()->dmisc20 = value / 10000; break;
20644 case 20: GuyH::getNPC()->dmisc21 = value / 10000; break;
20645 case 21: GuyH::getNPC()->dmisc22 = value / 10000; break;
20646 case 22: GuyH::getNPC()->dmisc23 = value / 10000; break;
20647 case 23: GuyH::getNPC()->dmisc24 = value / 10000; break;
20648 case 24: GuyH::getNPC()->dmisc25 = value / 10000; break;
20649 case 25: GuyH::getNPC()->dmisc26 = value / 10000; break;
20650 case 26: GuyH::getNPC()->dmisc27 = value / 10000; break;
20651 case 27: GuyH::getNPC()->dmisc28 = value / 10000; break;
20652 case 28: GuyH::getNPC()->dmisc28 = value / 10000; break;
20653 case 29: GuyH::getNPC()->dmisc30 = value / 10000; break;
20654 case 30: GuyH::getNPC()->dmisc31 = value / 10000; break;
20655 case 31: GuyH::getNPC()->dmisc32 = value / 10000; break;
20656 default: break;
20657 }
20658 break;
20659 }
20660
20661
20662 case NPCINVINC:
20663 {
20664 if(GuyH::loadNPC(ri->guyref, "npc->InvFrames") == SH::_NoError)
20665 GuyH::getNPC()->hclk = (int32_t)value/10000;
20666 }
20667 break;
20668
20669 case NPCSUPERMAN:
20670 {
20671 if(GuyH::loadNPC(ri->guyref, "npc->Invincible") == SH::_NoError)
20672 GuyH::getNPC()->superman = (int32_t)value/10000;
20673 }
20674 break;
20675
20676 case NPCHASITEM:
20677 {
20678 if(GuyH::loadNPC(ri->guyref, "npc->HasItem") == SH::_NoError)
20679 GuyH::getNPC()->itemguy = (value/10000)?1:0;
20680 }
20681 break;
20682
20683 case NPCRINGLEAD:
20684 {
20685 if(GuyH::loadNPC(ri->guyref, "npc->Ringleader") == SH::_NoError)
20686 GuyH::getNPC()->leader = (value/10000)?1:0;
20687 }
20688 break;
20689
20690 case NPCSHIELD:
20691 {
20692 int32_t indx = ri->d[rINDEX];
20693 if(GuyH::loadNPC(ri->guyref, "npc->Shield[]") == SH::_NoError)
20694 {
20695 switch(indx)
20696 {
20697 case 0:
20698 {
20699 (ri->d[rINDEX2])? (GuyH::getNPC()->flags |= inv_front) : (GuyH::getNPC()->flags &= ~inv_front);
20700 break;
20701 }
20702 case 1:
20703 {
20704 (ri->d[rINDEX2])? (GuyH::getNPC()->flags |= inv_left) : (GuyH::getNPC()->flags &= ~inv_left);
20705 break;
20706 }
20707 case 2:
20708 {
20709 (ri->d[rINDEX2])? (GuyH::getNPC()->flags |= inv_right) : (GuyH::getNPC()->flags &= ~inv_right);
20710 break;
20711 }
20712 case 3:
20713 {
20714 (ri->d[rINDEX2])? (GuyH::getNPC()->flags |= inv_back) : (GuyH::getNPC()->flags &= ~inv_back);
20715 break;
20716 }
20717 case 4: //shield can be broken
20718 {
20719 (ri->d[rINDEX2])? (GuyH::getNPC()->flags |= guy_bkshield) : (GuyH::getNPC()->flags &= ~guy_bkshield);
20720 break;
20721 }
20722 default:
20723 {
20724 Z_scripterrlog("Invalid Array Index passed to npc->Shield[]: %d\n", indx);
20725 break;
20726 }
20727 }
20728 }
20729 }
20730 break;
20731
20732 case NPCFROZENTILE:
20733 SET_NPC_VAR_INT(frozentile, "npc->FrozenTile"); break;
20734 case NPCFROZENCSET:
20735 SET_NPC_VAR_INT(frozencset, "npc->FrozenCSet"); break;
20736 case NPCFROZEN:
20737 SET_NPC_VAR_INT(frozenclock, "npc->Frozen"); break;
20738
20739 case NPCBEHAVIOUR:
20740 {
20741 if(GuyH::loadNPC(ri->guyref, "npc->Behaviour[]") != SH::_NoError)
20742 {
20743 break;
20744 }
20745 int32_t index = vbound(ri->d[rINDEX]/10000,0,4);
20746 switch(index)
20747 {
20748 case 0:
20749 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG1 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG1;
20750 break;
20751 case 1:
20752 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG2 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG2;
20753 break;
20754 case 2:
20755 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG3 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG3;
20756 break;
20757 case 3:
20758 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG4 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG4;
20759 break;
20760 case 4:
20761 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG5 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG5;
20762 break;
20763 case 5:
20764 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG6 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG6;
20765 break;
20766 case 6:
20767 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG7 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG7;
20768 break;
20769 case 7:
20770 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG8 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG8;
20771 break;
20772 case 8:
20773 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG9 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG9;
20774 break;
20775 case 9:
20776 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG10 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG10;
20777 break;
20778 case 10:
20779 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG11 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG11;
20780 break;
20781 case 11:
20782 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG12 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG12;
20783 break;
20784 case 12:
20785 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG13 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG13;
20786 break;
20787 case 13:
20788 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG14 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG14;
20789 break;
20790 case 14:
20791 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG15 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG15;
20792 break;
20793 case 15:
20794 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG16 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG16;
20795 break;
20796
20797
20798 default:
20799 break;
20800 }
20801
20802 break;
20803 }
20804 case NPCFALLCLK:
20805 if(GuyH::loadNPC(ri->guyref, "npc->Falling") == SH::_NoError)
20806 {
20807 if(GuyH::getNPC()->fallclk != 0 && value == 0)
20808 {
20809 GuyH::getNPC()->cs = GuyH::getNPC()->old_cset;
20810 GuyH::getNPC()->tile = GuyH::getNPC()->o_tile;
20811 }
20812 else if(GuyH::getNPC()->fallclk == 0 && value != 0) GuyH::getNPC()->old_cset = GuyH::getNPC()->cs;
20813 GuyH::getNPC()->fallclk = vbound(value/10000,0,70);
20814 }
20815 break;
20816 case NPCFALLCMB:
20817 if(GuyH::loadNPC(ri->guyref, "npc->FallCombo") == SH::_NoError)
20818 {
20819 GuyH::getNPC()->fallCombo = vbound(value/10000,0,MAXCOMBOS-1);
20820 }
20821 break;
20822 case NPCDROWNCLK:
20823 if(GuyH::loadNPC(ri->guyref, "npc->Drowning") == SH::_NoError)
20824 {
20825 if(GuyH::getNPC()->drownclk != 0 && value == 0)
20826 {
20827 GuyH::getNPC()->cs = GuyH::getNPC()->old_cset;
20828 GuyH::getNPC()->tile = GuyH::getNPC()->o_tile;
20829 }
20830 else if(GuyH::getNPC()->drownclk == 0 && value != 0) GuyH::getNPC()->old_cset = GuyH::getNPC()->cs;
20831 GuyH::getNPC()->drownclk = vbound(value/10000,0,70);
20832 }
20833 break;
20834 case NPCDROWNCMB:
20835 if(GuyH::loadNPC(ri->guyref, "npc->DrowningCombo") == SH::_NoError)
20836 {
20837 GuyH::getNPC()->drownCombo = vbound(value/10000,0,MAXCOMBOS-1);
20838 }
20839 case NPCFAKEZ:
20840 {
20841 if(GuyH::loadNPC(ri->guyref, "npc->FakeZ") == SH::_NoError)
20842 {
20843 if(!never_in_air(GuyH::getNPC()->id))
20844 {
20845 if(value < 0)
20846 GuyH::getNPC()->fakez = 0_zf;
20847 else
20848 GuyH::getNPC()->fakez = get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
20849
20850 if(GuyH::hasHero())
20851 Hero.setFakeZfix(get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
20852 }
20853 }
20854 }
20855 break;
20856 case NPCMOVEFLAGS:
20857 {
20858 if(GuyH::loadNPC(ri->guyref, "npc->MoveFlags[]") == SH::_NoError)
20859 {
20860 int32_t indx = ri->d[rINDEX]/10000;
20861 if(BC::checkBounds(indx, 0, 15, "npc->MoveFlags[]") == SH::_NoError)
20862 {
20863 //All bits, in order, of a single byte; just use bitwise
20864 int32_t bit = 1<<indx;
20865 if(value)
20866 GuyH::getNPC()->moveflags |= bit;
20867 else
20868 GuyH::getNPC()->moveflags &= ~bit;
20869 }
20870 }
20871 break;
20872 }
20873
20874 case NPCGLOWRAD:
20875 if(GuyH::loadNPC(ri->guyref, "npc->LightRadius") == SH::_NoError)
20876 {
20877 GuyH::getNPC()->glowRad = vbound(value/10000,0,255);
20878 }
20879 break;
20880 case NPCGLOWSHP:
20881 if(GuyH::loadNPC(ri->guyref, "npc->LightShape") == SH::_NoError)
20882 {
20883 GuyH::getNPC()->glowShape = vbound(value/10000,0,255);
20884 }
20885 break;
20886
20887 case NPCSHADOWSPR:
20888 if(GuyH::loadNPC(ri->guyref, "npc->ShadowSprite") == SH::_NoError)
20889 {
20890 GuyH::getNPC()->spr_shadow = vbound(value/10000,0,255);
20891 }
20892 break;
20893 case NPCSPAWNSPR:
20894 if(GuyH::loadNPC(ri->guyref, "npc->SpawnSprite") == SH::_NoError)
20895 {
20896 GuyH::getNPC()->spr_spawn = vbound(value/10000,0,255);
20897 }
20898 break;
20899 case NPCDEATHSPR:
20900 if(GuyH::loadNPC(ri->guyref, "npc->DeathSprite") == SH::_NoError)
20901 {
20902 GuyH::getNPC()->spr_death = vbound(value/10000,0,255);
20903 }
20904 break;
20905 case NPCSWHOOKED:
20906 break; //read-only
20907 case NPCCANFLICKER:
20908 if(GuyH::loadNPC(ri->guyref, "npc->InvFlicker") == SH::_NoError)
20909 {
20910 GuyH::getNPC()->setCanFlicker(value != 0);
20911 }
20912 break;
20913
20914
20915 ///----------------------------------------------------------------------------------------------------//
20916 //Game Information
20917
20918 case GAMEDEATHS:
20919 game->set_deaths(value/10000);
20920 break;
20921
20922 case GAMECHEAT:
20923 1 cheat=vbound(value/10000,0,4);
20924
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(maxcheat < cheat) maxcheat = cheat;
20925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(cheat) game->did_cheat(true);
20926 1 break;
20927
20928 case GAMEMAXCHEAT:
20929 maxcheat=vbound(value/10000,0,4);
20930 game->set_cheat(maxcheat);
20931 if(cheat > maxcheat) cheat = maxcheat;
20932 break;
20933
20934 case GAMETIME:
20935 1 game->set_time(value);
20936 1 break; // Can't multiply by 10000 or the maximum result is too big
20937
20938 case ACTIVESSSPEED:
20939 Hero.subscr_speed = vbound((value/10000),1,85);
20940 break; // Can't multiply by 10000 or the maximum result is too big
20941
20942 case GAMETIMEVALID:
20943 game->set_timevalid((value/10000)?1:0);
20944 break;
20945
20946 case GAMEHASPLAYED:
20947 game->set_hasplayed((value/10000)?1:0);
20948 break;
20949
20950 case TYPINGMODE:
20951 FFCore.kb_typing_mode = ((value/10000)?true:false);
20952 break;
20953
20954 case SKIPCREDITS:
20955 FFCore.skip_ending_credits = ((value/10000)?true:false);
20956 break;
20957
20958 case SKIPF6:
20959 set_qr(qr_NOCONTINUE,((value/10000)?1:0));
20960 break;
20961
20962
20963
20964 case GAMEGUYCOUNT:
20965 {
20966 26 int32_t mi2 = (currmap*MAPSCRSNORMAL)+(ri->d[rINDEX]/10000);
20967 26 game->guys[mi2]=value/10000;
20968 }
20969 26 break;
20970
20971 case GAMECONTSCR:
20972 88964 game->set_continue_scrn(value/10000);
20973 88964 break;
20974
20975 case GAMECONTDMAP:
20976 88964 game->set_continue_dmap(value/10000);
20977 88964 break;
20978
20979 case GAMEENTRSCR:
20980 88970 lastentrance=value/10000;
20981 88970 break;
20982
20983 case GAMEENTRDMAP:
20984 88970 lastentrance_dmap=value/10000;
20985 88970 break;
20986
20987 case GAMECOUNTERD:
20988 2705905 game->set_counter(value/10000, (ri->d[rINDEX])/10000);
20989 2705905 break;
20990
20991 case GAMEMCOUNTERD:
20992 551 game->set_maxcounter(value/10000, (ri->d[rINDEX])/10000);
20993 551 break;
20994
20995 case GAMEDCOUNTERD:
20996 8 game->set_dcounter(value/10000, (ri->d[rINDEX])/10000);
20997 8 break;
20998
20999 case GAMEGENERICD:
21000 game->set_generic(value/10000, (ri->d[rINDEX])/10000);
21001 break;
21002 case GAMEMISC:
21003 {
21004 int32_t indx = ri->d[rINDEX]/10000;
21005 if ( indx < 0 || indx > 31 )
21006 {
21007 Z_scripterrlog("Invalid index used to access Game->Misc: %d\n", indx);
21008 }
21009 else
21010 {
21011 QMisc.questmisc[indx] = (value/((get_qr(qr_OLDQUESTMISC)) ? 10000 : 1));
21012 }
21013 break;
21014 }
21015 case GAMEITEMSD:
21016 game->set_item((ri->d[rINDEX])/10000,(value!=0));
21017 break;
21018
21019 case DISABLEDITEM:
21020 {
21021 int id = (ri->d[rINDEX])/10000;
21022 if(unsigned(id) >= MAXITEMS)
21023 break;
21024 game->items_off[id]=value/10000;
21025 removeFromItemCache(itemsbuf[id].family);
21026 break;
21027 }
21028
21029 case GAMESUSPEND:
21030 {
21031 131 int32_t inx = (ri->d[rINDEX])/10000;
21032
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if ( (unsigned) inx > (susptLAST-1) )
21033 {
21034 Z_scripterrlog("Invalid array index [%d] passed to Gme->Suspend[]\n");
21035 }
21036 131 FFCore.system_suspend[inx]= ( (value) ? 1 : 0 );
21037 131 break;
21038 }
21039
21040 case GAMELITEMSD:
21041 64 game->lvlitems[(ri->d[rINDEX])/10000]=value/10000;
21042 64 break;
21043 case GAMELSWITCH:
21044 {
21045 int32_t ind = (ri->d[rINDEX])/10000;
21046 if(unsigned(ind) < MAXLEVELS)
21047 game->lvlswitches[ind]=value;
21048 break;
21049 }
21050 case GAMEGSWITCH:
21051 {
21052 int32_t ind = (ri->d[rINDEX])/10000;
21053 if(unsigned(ind) < NUM_GSWITCHES)
21054 game->gswitch_timers[ind]=value/10000;
21055 break;
21056 }
21057 case GAMEBOTTLEST:
21058 game->set_bottle_slot((ri->d[rINDEX])/10000,value/10000);
21059 break;
21060
21061 case TANGOARR:
21062 {
21063 int32_t inx = (ri->d[rINDEX])/10000;
21064 if ( ((unsigned)inx) > 255 )
21065 {
21066 Z_scripterrlog("Invalid index %d supplied to Game->Tango[].\n", inx);
21067 break;
21068 }
21069 else
21070 {
21071 FFCore.TangoArray[inx]=value/10000;
21072 break;
21073 }
21074 }
21075
21076 case GHOSTARR:
21077 {
21078 int32_t inx = (ri->d[rINDEX])/10000;
21079 if ( ((unsigned)inx) > 255 )
21080 {
21081 Z_scripterrlog("Invalid index %d supplied to Game->Ghost[].\n", inx);
21082 break;
21083 }
21084 else
21085 {
21086
21087 FFCore.GhostArray[inx]=value/10000;;
21088 break;
21089 }
21090 }
21091 case STDARR:
21092 {
21093 int32_t inx = (ri->d[rINDEX])/10000;
21094 if ( ((unsigned)inx) > 255 )
21095 {
21096 Z_scripterrlog("Invalid index %d supplied to Game->STD[].\n", inx);
21097 break;
21098 }
21099 else
21100 {
21101 FFCore.StdArray[inx]=value/10000;
21102 break;
21103 }
21104 }
21105
21106 case GAMEMISCSPR:
21107 {
21108 int32_t inx = (ri->d[rINDEX])/10000;
21109 if ( ((unsigned)inx) > sprMAX )
21110 {
21111 Z_scripterrlog("Invalid index %d supplied to Game->MiscSprites[].\n", inx);
21112 }
21113 else
21114 {
21115 QMisc.sprites[inx] = vbound(value/10000, 0, 255);
21116 }
21117 break;
21118 }
21119 case GAMEMISCSFX:
21120 {
21121 int32_t inx = (ri->d[rINDEX])/10000;
21122 if ( ((unsigned)inx) > sfxMAX )
21123 {
21124 Z_scripterrlog("Invalid index %d supplied to Game->MiscSFX[].\n", inx);
21125 }
21126 else
21127 {
21128 QMisc.miscsfx[inx] = vbound(value/10000, 0, 255);
21129 }
21130 break;
21131 }
21132 case GAMEOVERRIDEITEMS:
21133 {
21134 int32_t ind = (ri->d[rINDEX])/10000;
21135 if(unsigned(ind) >= itype_max)
21136 {
21137 Z_scripterrlog("Invalid index %d supplied to Game->OverrideItems[].\n", ind);
21138 }
21139 else
21140 {
21141 auto val = value/10000;
21142 game->OverrideItems[ind] = (val < -1 || val >= MAXITEMS) ? -2 : val;
21143 }
21144 break;
21145 }
21146 case GAMEEVENTDATA:
21147 {
21148 int32_t inx = (ri->d[rINDEX])/10000;
21149 if ( ((unsigned)inx) < FFCore.eventData.size() )
21150 {
21151 FFCore.eventData[inx] = value;
21152 }
21153 break;
21154 }
21155 case GAMEMOUSECURSOR:
21156 {
21157 int v = value/10000;
21158 if(v < 0 || v >= ZCM_MAX)
21159 break;
21160 game_mouse_index = v;
21161 game_mouse();
21162 break;
21163 }
21164 case GAMETRIGGROUPS:
21165 break; //read-only
21166
21167 case GAMELKEYSD:
21168 3 game->lvlkeys[(ri->d[rINDEX])/10000]=value/10000;
21169 3 break;
21170
21171 case GAMEGRAVITY:
21172 {
21173 int32_t indx = ri->d[rINDEX]/10000;
21174 if(indx < 0 || indx > 2)
21175 {
21176 Z_scripterrlog("Invalid index used to access Game->Gravity[]: %d\n", indx);
21177 }
21178 else
21179 {
21180 switch(indx)
21181 {
21182 case 0: //Gravity Strength
21183 zinit.gravity2 = value;
21184 break;
21185 case 1: //Terminal Velocity
21186 zinit.terminalv = value / 100;
21187 break;
21188 case 2: //Sprite Layer Threshold
21189 zinit.jump_hero_layer_threshold = value / 10000;
21190 break;
21191 }
21192 }
21193 break;
21194 }
21195
21196 case SCREENSTATED:
21197 {
21198 394 int32_t mi2 = (currmap*MAPSCRSNORMAL)+currscr;
21199
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 4 times.
394 (value)?setmapflag(mi2, 1<<((ri->d[rINDEX])/10000)) : unsetmapflag(mi2, 1 << ((ri->d[rINDEX]) / 10000));
21200 }
21201 394 break;
21202 case SCREENEXSTATED:
21203 {
21204 int32_t mi2 = (currmap*MAPSCRSNORMAL)+currscr;
21205 (value)?setxmapflag(mi2, 1<<((ri->d[rINDEX])/10000)) : unsetxmapflag(mi2, 1 << ((ri->d[rINDEX]) / 10000));
21206 }
21207 break;
21208 case SCREENLENSSHOWS:
21209 {
21210 int ind = ri->d[rINDEX]/10000;
21211 if(ind < 0 || ind > 6)
21212 Z_scripterrlog("Bad index Screen->LensShows[%d]\n",ind);
21213 else
21214 {
21215 SETFLAG(tmpscr->lens_show, 1<<ind, value);
21216 if(value) tmpscr->lens_hide &= ~(1<<ind);
21217 }
21218 break;
21219 }
21220 case SCREENLENSHIDES:
21221 {
21222 int ind = ri->d[rINDEX]/10000;
21223 if(ind < 0 || ind > 6)
21224 Z_scripterrlog("Bad index Screen->LensHides[%d]\n",ind);
21225 else
21226 {
21227 SETFLAG(tmpscr->lens_hide, 1<<ind, value);
21228 if(value) tmpscr->lens_show &= ~(1<<ind);
21229 }
21230 break;
21231 }
21232 case SCREENSCRDATASIZE:
21233 {
21234 auto mi = get_total_mi();
21235 if(mi < 0) break;
21236 game->scriptDataResize(mi, value/10000);
21237 break;
21238 }
21239 case SCREENSCRDATA:
21240 {
21241 auto mi = get_total_mi();
21242 if(mi < 0) break;
21243 size_t indx = ri->d[rINDEX]/10000;
21244 if(indx >= game->scriptDataSize(mi))
21245 {
21246 Z_scripterrlog("Invalid index passed to Screen->Data[]: %d\n", indx);
21247 break;
21248 }
21249 game->screen_data[mi][indx] = value;
21250 break;
21251 }
21252
21253 case SCREENSTATEDD:
21254 {
21255 649 int32_t mi2 = ri->d[rINDEX]/10000;
21256 649 mi2 -= 8*(mi2/MAPSCRS);
21257
21258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 649 times.
649 if(BC::checkMapID(mi2>>7, "Game->SetScreenState") == SH::_NoError)
21259
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 455 times.
649 (value)?setmapflag(mi2, 1<<(ri->d[rINDEX2]/10000)) : unsetmapflag(mi2, 1 << (ri->d[rINDEX2] / 10000), true);
21260 }
21261 649 break;
21262
21263 case GAMEGUYCOUNTD:
21264 game->guys[(currmap*MAPSCRSNORMAL)+(ri->d[rINDEX]/10000)] = value / 10000;
21265 break;
21266
21267 case GAMECLICKFREEZE:
21268 disableClickToFreeze=value==0;
21269 break;
21270
21271
21272 case NOACTIVESUBSC:
21273 Hero.stopSubscreenFalling((value/10000)?1:0);
21274 break;
21275
21276 ///----------------------------------------------------------------------------------------------------//
21277 //BottleTypes
21278 case BOTTLECOUNTER:
21279 {
21280 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Counter[]"))
21281 {
21282 int32_t indx = ri->d[rINDEX]/10000;
21283 int32_t ctr = vbound(value/10000, -1, MAX_COUNTERS-1);
21284 if(unsigned(indx) > 2)
21285 {
21286 Z_scripterrlog("Invalid index %d supplied to bottledata->Counter[].\n", indx);
21287 break;
21288 }
21289 ptr->counter[indx] = ctr;
21290 }
21291 }
21292 break;
21293
21294 case BOTTLEAMOUNT:
21295 {
21296 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Amount[]"))
21297 {
21298 int32_t indx = ri->d[rINDEX]/10000;
21299 int32_t amnt = vbound(value/10000, 0, 65535);
21300 if(unsigned(indx) > 2)
21301 {
21302 Z_scripterrlog("Invalid index %d supplied to bottledata->Amount[].\n", indx);
21303 break;
21304 }
21305 ptr->amount[indx] = amnt;
21306 }
21307 }
21308 break;
21309
21310 case BOTTLEPERCENT:
21311 {
21312 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "IsPercent[]"))
21313 {
21314 int32_t indx = ri->d[rINDEX]/10000;
21315 if(unsigned(indx) > 2)
21316 {
21317 Z_scripterrlog("Invalid index %d supplied to bottledata->IsPercent[].\n", indx);
21318 break;
21319 }
21320 SETFLAG(ptr->flags, 1<<indx, value);
21321 }
21322 }
21323 break;
21324
21325 case BOTTLEFLAGS:
21326 {
21327 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Flags[]"))
21328 {
21329 int32_t indx = ri->d[rINDEX]/10000;
21330 if(unsigned(indx) > 3)
21331 {
21332 Z_scripterrlog("Invalid index %d supplied to bottledata->Flags[].\n", indx);
21333 break;
21334 }
21335 int32_t flag = 0;
21336 switch(indx)
21337 {
21338 case 0: flag = BTFLAG_AUTOONDEATH; break;
21339 case 1: flag = BTFLAG_ALLOWIFFULL; break;
21340 case 2: flag = BTFLAG_CURESWJINX; break;
21341 case 3: flag = BTFLAG_CUREITJINX; break;
21342 }
21343 SETFLAG(ptr->flags, flag, value);
21344 }
21345 }
21346 break;
21347
21348 case BOTTLENEXT:
21349 {
21350 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "NextType"))
21351 {
21352 ptr->next_type = vbound(value/10000, 0, 64);
21353 }
21354 }
21355 break;
21356 ///----------------------------------------------------------------------------------------------------//
21357 //BottleShops
21358 case BSHOPFILL:
21359 {
21360 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Fill[]"))
21361 {
21362 int32_t indx = ri->d[rINDEX]/10000;
21363 if(unsigned(indx) > 2)
21364 {
21365 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Fill[].\n", indx);
21366 break;
21367 }
21368 ptr->fill[indx] = vbound(value/10000, 0, 64);
21369 }
21370 }
21371 break;
21372
21373 case BSHOPCOMBO:
21374 {
21375 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Combo[]"))
21376 {
21377 int32_t indx = ri->d[rINDEX]/10000;
21378 if(unsigned(indx) > 2)
21379 {
21380 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Combo[].\n", indx);
21381 break;
21382 }
21383 ptr->comb[indx] = vbound(value/10000, 0, MAXCOMBOS-1);
21384 }
21385 }
21386 break;
21387
21388 case BSHOPCSET:
21389 {
21390 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "CSet[]"))
21391 {
21392 int32_t indx = ri->d[rINDEX]/10000;
21393 if(unsigned(indx) > 2)
21394 {
21395 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->CSet[].\n", indx);
21396 break;
21397 }
21398 ptr->cset[indx] = vbound(value/10000, 0, 11);
21399 }
21400 }
21401 break;
21402
21403 case BSHOPPRICE:
21404 {
21405 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Price[]"))
21406 {
21407 int32_t indx = ri->d[rINDEX]/10000;
21408 if(unsigned(indx) > 2)
21409 {
21410 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Price[].\n", indx);
21411 break;
21412 }
21413 ptr->price[indx] = vbound(value/10000, 0, 65535);
21414 }
21415 }
21416 break;
21417
21418 case BSHOPSTR:
21419 {
21420 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "InfoString[]"))
21421 {
21422 int32_t indx = ri->d[rINDEX]/10000;
21423 if(unsigned(indx) > 2)
21424 {
21425 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->InfoString[].\n", indx);
21426 break;
21427 }
21428 ptr->str[indx] = vbound(value/10000, 0, 65535);
21429 }
21430 }
21431 break;
21432 ///----------------------------------------------------------------------------------------------------//
21433 //DMap Information
21434
21435 #define SET_DMAP_VAR(member, str) \
21436 { \
21437 int32_t ID = ri->d[rINDEX] / 10000; \
21438 if(BC::checkDMapID(ID, str) == SH::_NoError) \
21439 DMaps[ID].member = value / 10000; \
21440 }
21441
21442 case DMAPFLAGSD:
21443 SET_DMAP_VAR(flags, "Game->DMapFlags") break;
21444
21445 case DMAPLEVELD:
21446 SET_DMAP_VAR(level, "Game->DMapLevel") break;
21447
21448 case DMAPCOMPASSD:
21449 SET_DMAP_VAR(compass, "Game->DMapCompass") break;
21450
21451 case DMAPCONTINUED:
21452 SET_DMAP_VAR(cont, "Game->DMapContinue") break;
21453
21454 case DMAPLEVELPAL:
21455 {
21456 889 int32_t ID = ri->d[rINDEX] / 10000;
21457 889 int32_t pal = value/10000;
21458 889 pal = vbound(pal, 0, 0x1FF);
21459
21460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 889 times.
889 if(BC::checkDMapID(ID, "Game->DMapPalette") == SH::_NoError)
21461 889 DMaps[ID].color = pal;
21462
21463
2/2
✓ Branch 0 taken 878 times.
✓ Branch 1 taken 11 times.
889 if(ID == currdmap)
21464 {
21465 11 loadlvlpal(DMaps[ID].color);
21466 11 currcset = DMaps[ID].color;
21467 11 }
21468 889 break;
21469 }
21470
21471 case DMAPMIDID:
21472 {
21473 int32_t ID = ri->d[rINDEX] / 10000;
21474
21475 if(BC::checkDMapID(ID, "Game->DMapMIDI") == SH::_NoError)
21476 {
21477 // Based on play_DmapMusic
21478 switch(value / 10000)
21479 {
21480 case -6:
21481 DMaps[ID].midi = 2;
21482 break; // Dungeon
21483
21484 case -3:
21485 DMaps[ID].midi = 3;
21486 break; // Level 9
21487
21488 case -2:
21489 DMaps[ID].midi = 1;
21490 break; // Overworld
21491
21492 case 0:
21493 DMaps[ID].midi = 0;
21494 break; // None
21495
21496 default:
21497 DMaps[ID].midi = value / 10000 + 3;
21498 }
21499 }
21500
21501 break;
21502 }
21503
21504 ///----------------------------------------------------------------------------------------------------//
21505 //Screen->ComboX
21506 case COMBODD:
21507 {
21508 120341 int32_t pos = (ri->d[rINDEX])/10000;
21509 120341 int32_t val = (value/10000);
21510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120341 times.
120341 if ( ((unsigned) pos) > 175 )
21511 {
21512 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboD[]\n", pos);
21513 }
21514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120341 times.
120341 else if ( ((unsigned) val) >= MAXCOMBOS )
21515 {
21516 Z_scripterrlog("Invalid combo ID %d used to write to Screen->ComboD[]\n", val);
21517 }
21518 else
21519 {
21520 120341 screen_combo_modify_preroutine(tmpscr,pos);
21521 120341 tmpscr->data[pos]=(val);
21522 120341 screen_combo_modify_postroutine(tmpscr,pos);
21523 }
21524 }
21525 120341 break;
21526
21527 case COMBOCD:
21528 {
21529 6481 int32_t pos = (ri->d[rINDEX])/10000;
21530 6481 int32_t val = (value/10000); //cset
21531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6481 times.
6481 if ( ((unsigned) pos) > 175 )
21532 {
21533 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboC[]\n", pos);
21534 }
21535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6481 times.
6481 else if ( ((unsigned) val) >= 15 )
21536 {
21537 Z_scripterrlog("Invalid CSet ID %d used to write to Screen->ComboC[]\n", val);
21538 }
21539 else
21540 {
21541 6481 screen_combo_modify_preroutine(tmpscr,pos);
21542 6481 tmpscr->cset[pos]=(val)&15;
21543 6481 screen_combo_modify_postroutine(tmpscr,pos);
21544 }
21545 }
21546 6481 break;
21547
21548 case COMBOFD:
21549 {
21550 int32_t pos = (ri->d[rINDEX])/10000;
21551 int32_t val = (value/10000); //flag
21552 if ( ((unsigned) pos) > 175 )
21553 {
21554 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboF[]\n", pos);
21555 }
21556 else if ( ((unsigned) val) >= 256 )
21557 {
21558 Z_scripterrlog("Invalid Flag ID %d used to write to Screen->ComboF[]\n", val);
21559 }
21560
21561 else
21562 tmpscr->sflag[pos]=(val);
21563 }
21564 break;
21565
21566 case COMBOTD:
21567 {
21568 3560 int32_t pos = (ri->d[rINDEX])/10000;
21569 3560 int32_t val = (value/10000); //type
21570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3560 times.
3560 if ( ((unsigned) pos) > 175 )
21571 {
21572 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboT[]\n", pos);
21573 }
21574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3560 times.
3560 else if ( ((unsigned) val) >= 256 )
21575 {
21576 Z_scripterrlog("Invalid Flag ID %d used to write to Screen->ComboT[]\n", val);
21577 }
21578 else
21579 {
21580 3560 auto cid = tmpscr->data[pos];
21581 3560 screen_combo_modify_pre(cid);
21582 3560 combobuf[cid].type=val;
21583 3560 screen_combo_modify_post(cid);
21584 }
21585 }
21586 3560 break;
21587
21588 case COMBOID:
21589 {
21590 int32_t pos = (ri->d[rINDEX])/10000;
21591 int32_t val = (value/10000); //iflag
21592 if ( ((unsigned) pos) > 175 )
21593 {
21594 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboI[]\n", pos);
21595 }
21596 else if ( ((unsigned) val) >= 256 )
21597 {
21598 Z_scripterrlog("Invalid Flag ID %d used to write to Screen->ComboI[]\n", val);
21599 }
21600
21601 else
21602 combobuf[tmpscr->data[pos]].flag=val;
21603 }
21604 break;
21605
21606 case COMBOSD:
21607 {
21608 81346 int32_t pos = (ri->d[rINDEX])/10000;
21609 81346 int32_t val = (value/10000); //iflag
21610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81346 times.
81346 if ( ((unsigned) pos) > 175 )
21611 {
21612 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboS[]\n", pos);
21613 }
21614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81346 times.
81346 else if ( ((unsigned) val) >= 16 )//solidity 1, 2, 4, 8 max 15
21615 {
21616 Z_scripterrlog("Invalid Flag ID %d used to write to Screen->ComboS[]\n", val);
21617 }
21618 else
21619 {
21620 81346 combobuf[tmpscr->data[pos]].walk &= ~0x0F;
21621 81346 combobuf[tmpscr->data[pos]].walk |= (val)&0x0F;
21622 }
21623 }
21624 81346 break;
21625
21626 case COMBOED:
21627 {
21628 int32_t pos = (ri->d[rINDEX])/10000;
21629 int32_t val = (value/10000); //iflag
21630 if ( ((unsigned) pos) > 175 )
21631 {
21632 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboE[]\n", pos);
21633 }
21634 else if ( ((unsigned) val) >= 16 )//solidity 1, 2, 4, 8 max 15
21635 {
21636 Z_scripterrlog("Invalid Flag ID %d used to write to Screen->ComboE[]\n", val);
21637 }
21638 else
21639 {
21640 combobuf[tmpscr->data[pos]].walk &= ~0xF0;
21641 combobuf[tmpscr->data[pos]].walk |= ((val)&0x0F)<<4;
21642 }
21643 }
21644 break;
21645
21646 ///----------------------------------------------------------------------------------------------------//
21647 //Game->SetComboX
21648 case COMBODDM:
21649 {
21650 5356632 int32_t pos = (ri->d[rINDEX])/10000;
21651 5356632 int32_t sc = (ri->d[rEXP1]/10000);
21652 5356632 int32_t m = (ri->d[rINDEX2]/10000)-1;
21653
1/2
✓ Branch 0 taken 5356632 times.
✗ Branch 1 not taken.
5356632 int32_t scr = zc_max(m*MAPSCRS+sc,0);
21654 5356632 int32_t layr = whichlayer(scr);
21655
21656 //if(!(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)) break;
21657
21658
2/4
✓ Branch 0 taken 5356632 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5356632 times.
5356632 if(pos < 0 || pos >= 176)
21659 {
21660 Z_scripterrlog("Invalid combo position (%d) passed to SetComboData", pos);
21661 break;
21662 }
21663
1/2
✓ Branch 0 taken 5356632 times.
✗ Branch 1 not taken.
5356632 if(scr < 0)
21664 {
21665 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboData", scr);
21666 break;
21667 }
21668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5356632 times.
5356632 if(sc >= MAPSCRS)
21669 {
21670 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboData", sc);
21671 break;
21672 }
21673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5356632 times.
5356632 if(unsigned(m) >= map_count)
21674 {
21675 Z_scripterrlog("Invalid Map ID (%d) passed to SetComboData", m);
21676 break;
21677 }
21678 5356632 int32_t combo = vbound(value/10000,0,MAXCOMBOS);
21679
2/2
✓ Branch 0 taken 5356419 times.
✓ Branch 1 taken 213 times.
5356632 if(scr==(currmap*MAPSCRS+currscr))
21680 {
21681 213 screen_combo_modify_preroutine(tmpscr,pos);
21682
21683 213 }
21684
21685 5356632 TheMaps[scr].data[pos]=combo;
21686
21687
2/2
✓ Branch 0 taken 5356419 times.
✓ Branch 1 taken 213 times.
5356632 if(scr==(currmap*MAPSCRS+currscr))
21688 {
21689 213 tmpscr->data[pos] = combo;
21690 213 screen_combo_modify_postroutine(tmpscr,pos);
21691 //Start the script for the new combo
21692 213 int index = get_combopos_ref(pos, 0);
21693 213 FFCore.reset_script_engine_data(ScriptType::Combo, index);
21694 //Not ure if combodata arrays clean themselves up, or leak. -Z
21695 //Not sure if this could result in stack corruption.
21696 213 }
21697
21698
2/2
✓ Branch 0 taken 5350083 times.
✓ Branch 1 taken 6549 times.
5356632 if(layr>-1)
21699 {
21700 6549 tmpscr2[layr].data[pos]=combo;
21701 6549 int index = get_combopos_ref(pos, layr + 1);
21702 6549 FFCore.reset_script_engine_data(ScriptType::Combo, index);
21703 6549 }
21704 }
21705 5356632 break;
21706
21707 case COMBOCDM:
21708 {
21709 5344380 int32_t pos = (ri->d[rINDEX])/10000;
21710 5344380 int32_t sc = (ri->d[rEXP1]/10000);
21711 5344380 int32_t m = (ri->d[rINDEX2]/10000)-1;
21712
1/2
✓ Branch 0 taken 5344380 times.
✗ Branch 1 not taken.
5344380 int32_t scr = zc_max(m*MAPSCRS+sc,0);
21713
21714 //if(!(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)) break;
21715
21716
2/4
✓ Branch 0 taken 5344380 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5344380 times.
5344380 if(pos < 0 || pos >= 176)
21717 {
21718 Z_scripterrlog("Invalid combo position (%d) passed to SetComboCSet", pos);
21719 break;
21720 }
21721
1/2
✓ Branch 0 taken 5344380 times.
✗ Branch 1 not taken.
5344380 if(scr < 0)
21722 {
21723 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboCSet", scr);
21724 break;
21725 }
21726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5344380 times.
5344380 if(sc >= MAPSCRS)
21727 {
21728 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboCSet", sc);
21729 break;
21730 }
21731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5344380 times.
5344380 if(unsigned(m) >= map_count)
21732 {
21733 Z_scripterrlog("Invalid Map ID (%d) passed to SetComboCSet", m);
21734 break;
21735 }
21736
21737 5344380 TheMaps[scr].cset[pos]=(value/10000)&15;
21738
21739
2/2
✓ Branch 0 taken 5344340 times.
✓ Branch 1 taken 40 times.
5344380 if(scr==(currmap*MAPSCRS+currscr))
21740 40 tmpscr->cset[pos] = value/10000;
21741
21742 5344380 int32_t layr = whichlayer(scr);
21743
21744
2/2
✓ Branch 0 taken 3042 times.
✓ Branch 1 taken 5341338 times.
5344380 if(layr>-1)
21745 3042 tmpscr2[layr].cset[pos]=(value/10000)&15;
21746 }
21747 5344380 break;
21748
21749 case COMBOFDM:
21750 {
21751 32221 int32_t pos = (ri->d[rINDEX])/10000;
21752 32221 int32_t sc = (ri->d[rEXP1]/10000);
21753 32221 int32_t m = (ri->d[rINDEX2]/10000)-1;
21754
1/2
✓ Branch 0 taken 32221 times.
✗ Branch 1 not taken.
32221 int32_t scr = zc_max(m*MAPSCRS+sc,0);
21755
21756 //if(!(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)) break;
21757
21758
2/4
✓ Branch 0 taken 32221 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32221 times.
32221 if(pos < 0 || pos >= 176)
21759 {
21760 Z_scripterrlog("Invalid combo position (%d) passed to SetComboFlag", pos);
21761 break;
21762 }
21763
1/2
✓ Branch 0 taken 32221 times.
✗ Branch 1 not taken.
32221 if(scr < 0)
21764 {
21765 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboFlag", scr);
21766 break;
21767 }
21768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32221 times.
32221 if(sc >= MAPSCRS)
21769 {
21770 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboFlag", sc);
21771 break;
21772 }
21773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32221 times.
32221 if(unsigned(m) >= map_count)
21774 {
21775 Z_scripterrlog("Invalid Map ID (%d) passed to SetComboFlag", m);
21776 break;
21777 }
21778
21779 32221 TheMaps[scr].sflag[pos]=value/10000;
21780
21781
2/2
✓ Branch 0 taken 32153 times.
✓ Branch 1 taken 68 times.
32221 if(scr==(currmap*MAPSCRS+currscr))
21782 68 tmpscr->sflag[pos] = value/10000;
21783
21784 32221 int32_t layr = whichlayer(scr);
21785
21786
2/2
✓ Branch 0 taken 32210 times.
✓ Branch 1 taken 11 times.
32221 if(layr>-1)
21787 11 tmpscr2[layr].sflag[pos]=value/10000;
21788 }
21789 32221 break;
21790
21791 case COMBOTDM:
21792 {
21793 760 int32_t pos = (ri->d[rINDEX])/10000;
21794 760 int32_t sc = (ri->d[rEXP1]/10000);
21795 760 int32_t m = (ri->d[rINDEX2]/10000)-1;
21796
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 int32_t scr = zc_max(m*MAPSCRS+sc,0);
21797
21798 //if(!(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count))
21799 // break;
21800
21801
2/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 760 times.
760 if(pos < 0 || pos >= 176)
21802 {
21803 Z_scripterrlog("Invalid combo position (%d) passed to SetComboType", pos);
21804 break;
21805 }
21806
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(scr < 0)
21807 {
21808 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboType", scr);
21809 break;
21810 }
21811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(sc >= MAPSCRS)
21812 {
21813 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboType", sc);
21814 break;
21815 }
21816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(unsigned(m) >= map_count)
21817 {
21818 Z_scripterrlog("Invalid Map ID (%d) passed to SetComboType", m);
21819 break;
21820 }
21821
21822 760 int32_t cdata = TheMaps[scr].data[pos];
21823 760 screen_combo_modify_pre(cdata);
21824 760 combobuf[cdata].type=value/10000;
21825 760 screen_combo_modify_post(cdata);
21826 }
21827 760 break;
21828
21829 case COMBOIDM:
21830 {
21831 int32_t pos = (ri->d[rINDEX])/10000;
21832 int32_t sc = (ri->d[rEXP1]/10000);
21833 int32_t m = (ri->d[rINDEX2]/10000)-1;
21834 int32_t scr = zc_max(m*MAPSCRS+sc,0);
21835
21836 //if(!(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count))
21837 // break;
21838
21839 if(pos < 0 || pos >= 176)
21840 {
21841 Z_scripterrlog("Invalid combo position (%d) passed to GetComboInherentFlag", pos);
21842 break;
21843 }
21844 if(scr < 0)
21845 {
21846 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboInherentFlag", scr);
21847 break;
21848 }
21849 if(sc >= MAPSCRS)
21850 {
21851 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboInherentFlag", sc);
21852 break;
21853 }
21854 if(unsigned(m) >= map_count)
21855 {
21856 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboInherentFlag", m);
21857 break;
21858 }
21859
21860 combobuf[TheMaps[scr].data[pos]].flag=value/10000;
21861 }
21862 break;
21863
21864 case COMBOSDM:
21865 {
21866 //This is how it was in 2.50.1-2
21867 int32_t pos = (ri->d[rINDEX])/10000;
21868 int32_t scr = (ri->d[rINDEX2]/10000)*MAPSCRS+(ri->d[rEXP1]/10000);
21869 //This (below) us the precise code from 2.50.1 (?)
21870 //int32_t scr = zc_max((ri->d[rINDEX2]/10000)*MAPSCRS+(ri->d[rEXP1]/10000),0); //Not below 0.
21871
21872 //if(pos < 0 || pos >= 176 || scr < 0) break;
21873 if(pos < 0 || pos >= 176)
21874 {
21875 Z_scripterrlog("Invalid combo position (%d) passed to GetSolid", pos);
21876 break;
21877 }
21878 if(scr < 0)
21879 {
21880 Z_scripterrlog("Invalid MapScreen ID (%d) passed to GetSolid", scr);
21881 break;
21882 }
21883 combobuf[TheMaps[scr].data[pos]].walk &= ~0x0F;
21884 combobuf[TheMaps[scr].data[pos]].walk |= (value/10000)&15;
21885 }
21886 break;
21887
21888 ///----------------------------------------------------------------------------------------------------//
21889 //Screen Variables
21890
21891 #define SET_SCREENDATA_VAR_INT32(member, str) \
21892 { \
21893 tmpscr->member = vbound((value / 10000),-214747,214747); \
21894 } \
21895
21896 #define SET_SCREENDATA_VAR_INT16(member, str) \
21897 { \
21898 tmpscr->member = vbound((value / 10000),0,32767); \
21899 } \
21900
21901 #define SET_SCREENDATA_VAR_BYTE(member, str) \
21902 { \
21903 tmpscr->member = vbound((value / 10000),0,255); \
21904 } \
21905
21906 #define SET_SCREENDATA_VAR_INDEX32(member, str, indexbound) \
21907 { \
21908 int32_t indx = ri->d[rINDEX] / 10000; \
21909 tmpscr->member[indx] = vbound((value / 10000),-214747,214747); \
21910 } \
21911
21912 #define SET_SCREENDATA_VAR_INDEX16(member, str, indexbound) \
21913 { \
21914 int32_t indx = ri->d[rINDEX] / 10000; \
21915 tmpscr->member[indx] = vbound((value / 10000),-32767,32767); \
21916 } \
21917
21918 #define SET_SCREENDATA_BYTE_INDEX(member, str, indexbound) \
21919 { \
21920 int32_t indx = ri->d[rINDEX] / 10000; \
21921 tmpscr->member[indx] = vbound((value / 10000),0,255); \
21922 }
21923 #define SET_SCREENDATA_LAYER_INDEX(member, str, indexbound) \
21924 { \
21925 int32_t indx = ri->d[rINDEX] / 10000; \
21926 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
21927 if(indx < 1 || indx > indexbound ) \
21928 { \
21929 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
21930 } \
21931 else tmpscr->member[indx-1] = vbound((value / 10000),0,255); \
21932 }
21933 ///max screen id is higher! vbound properly... -Z
21934 #define SET_SCREENDATA_LAYERSCREEN_INDEX(member, str, indexbound) \
21935 { \
21936 int32_t indx = ri->d[rINDEX] / 10000; \
21937 int32_t scrn_id = value/10000; \
21938 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
21939 if(indx < 1 || indx > indexbound ) \
21940 { \
21941 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
21942 } \
21943 else if ( scrn_id > MAPSCRS ) \
21944 { \
21945 Z_scripterrlog("Script attempted to use a mapdata->LayerScreen[%d].\n",scrn_id); \
21946 Z_scripterrlog("Valid Screen values are (0) through (%d).\n",MAPSCRS); \
21947 } \
21948 else tmpscr->member[indx-1] = vbound((scrn_id),0,MAPSCRS); \
21949 }
21950
21951 #define SET_SCREENDATA_FLAG(member, str) \
21952 { \
21953 int32_t flag = (value/10000); \
21954 if ( flag != 0 ) \
21955 { \
21956 tmpscr->member|=flag; \
21957 } \
21958 else tmpscr->.member|= ~flag; \
21959 } \
21960
21961 #define SET_SCREENDATA_BOOL_INDEX(member, str, indexbound) \
21962 { \
21963 int32_t indx = ri->d[rINDEX] / 10000; \
21964 if(indx < 0 || indx > indexbound ) \
21965 { \
21966 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", (indx), str); \
21967 break; \
21968 } \
21969 tmpscr->member[indx] =( (value/10000) ? 1 : 0 ); \
21970 }
21971
21972 #define SET_FFC_BOOL_INDEX(member, str, indexbound) \
21973 { \
21974 int32_t indx = ri->d[rINDEX] / 10000; \
21975 if(indx < 0 || indx > indexbound ) \
21976 { \
21977 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", (indx), str); \
21978 break; \
21979 } \
21980 tmpscr->ffcs[indx].member =( (value/10000) ? 1 : 0 ); \
21981 }
21982
21983
21984 case SCREENDATAVALID: SET_SCREENDATA_VAR_BYTE(valid, "Valid"); break; //b
21985 case SCREENDATAGUY: SET_SCREENDATA_VAR_BYTE(guy, "Guy"); break; //b
21986 case SCREENDATASTRING: SET_SCREENDATA_VAR_INT32(str, "String"); break; //w
21987 case SCREENDATAROOM: SET_SCREENDATA_VAR_BYTE(room, "RoomType"); break; //b
21988 case SCREENDATAITEM:
21989 {
21990 auto v = vbound((value / 10000),-1,255);
21991 if(v > -1)
21992 tmpscr->item = v;
21993 tmpscr->hasitem = v > -1;
21994 break;
21995 }
21996 case SCREENDATAHASITEM: SET_SCREENDATA_VAR_BYTE(hasitem, "HasItem"); break; //b
21997 case SCREENDATATILEWARPTYPE: SET_SCREENDATA_BYTE_INDEX(tilewarptype, "TileWarpType", 3); break; //b, 4 of these
21998 //case SCREENDATATILEWARPOVFLAGS: SET_SCREENDATA_VAR_BYTE(tilewarpoverlayflags, "TileWarpOverlayFlags"); break; //b, tilewarpoverlayflags
21999 case SCREENDATADOORCOMBOSET: SET_SCREENDATA_VAR_INT32(door_combo_set, "DoorComboSet"); break; //w
22000 case SCREENDATAWARPRETX: SET_SCREENDATA_BYTE_INDEX(warpreturnx, "WarpReturnX", 3); break; //b, 4 of these
22001 case SCREENDATAWARPRETY: SET_SCREENDATA_BYTE_INDEX(warpreturny, "WarpReturnY", 3); break; //b, 4 of these
22002 case SCREENDATAWARPRETURNC: SET_SCREENDATA_VAR_INT32(warpreturnc, "WarpReturnC"); break; //w
22003 case SCREENDATASTAIRX: SET_SCREENDATA_VAR_BYTE(stairx, "StairsX"); break; //b
22004 case SCREENDATASTAIRY: SET_SCREENDATA_VAR_BYTE(stairy, "StairsY"); break; //b
22005 case SCREENDATAITEMX: SET_SCREENDATA_VAR_BYTE(itemx, "ItemX"); break; //itemx
22006 case SCREENDATAITEMY: SET_SCREENDATA_VAR_BYTE(itemy, "ItemY"); break; //itemy
22007 case SCREENDATACOLOUR: SET_SCREENDATA_VAR_INT32(color, "CSet"); break; //w
22008 case SCREENDATAENEMYFLAGS: SET_SCREENDATA_VAR_BYTE(enemyflags, "EnemyFlags"); break; //b
22009 case SCREENDATADOOR: SET_SCREENDATA_BYTE_INDEX(door, "Door", 3); break; //b, 4 of these
22010 case SCREENDATATILEWARPDMAP: SET_SCREENDATA_VAR_INDEX32(tilewarpdmap, "TileWarpDMap", 3); break; //w, 4 of these
22011 case SCREENDATATILEWARPSCREEN: SET_SCREENDATA_BYTE_INDEX(tilewarpscr, "TileWarpScreen", 3); break; //b, 4 of these
22012 case SCREENDATAEXITDIR: SET_SCREENDATA_VAR_BYTE(exitdir, "ExitDir"); break; //b
22013 case SCREENDATAENEMY:
22014 {
22015 int32_t indx = ri->d[rINDEX] / 10000;
22016 int32_t enemyid = value/10000;
22017 if ( ((unsigned)enemyid) > MAXGUYS )
22018 {
22019 Z_scripterrlog("Invaid enemy ID (%d) passed to Screen->%s.", enemyid,"Enemy[]"); \
22020 break;
22021 }
22022 if(unsigned(indx) > 9)
22023 {
22024 Z_scripterrlog("Invalid index (%d) used for Screen->Enemy[]", indx);
22025 break;
22026 }
22027 tmpscr->enemy[indx] = enemyid;
22028 break;
22029 }
22030 //case SCREENDATAENEMY: SET_SCREENDATA_VAR_INDEX32(enemy, "Enemy", 9); break; //w, 10 of these
22031 case SCREENDATAPATTERN: SET_SCREENDATA_VAR_BYTE(pattern, "Pattern"); break; //b
22032 case SCREENDATASIDEWARPTYPE: SET_SCREENDATA_BYTE_INDEX(sidewarptype, "SideWarpType", 3); break; //b, 4 of these
22033 //case SCREENDATASIDEWARPOVFLAGS: SET_SCREENDATA_VAR_BYTE(sidewarpoverlayflags, "SideWarpOverlayFlags"); break; //b
22034 case SCREENDATAWARPARRIVALX: SET_SCREENDATA_VAR_BYTE(warparrivalx, "WarpArrivalX"); break; //b
22035 case SCREENDATAWARPARRIVALY: SET_SCREENDATA_VAR_BYTE(warparrivaly, "WarpArrivalY"); break; //b
22036 case SCREENDATAPATH: SET_SCREENDATA_BYTE_INDEX(path, "MazePath", 3); break; //b, 4 of these
22037 case SCREENDATASIDEWARPSC: SET_SCREENDATA_BYTE_INDEX(sidewarpscr, "SideWarpScreen", 3); break; //b, 4 of these
22038 case SCREENDATASIDEWARPDMAP: SET_SCREENDATA_VAR_INDEX32(sidewarpdmap, "SideWarpDMap", 3); break; //w, 4 of these
22039 case SCREENDATASIDEWARPINDEX: SET_SCREENDATA_VAR_BYTE(sidewarpindex, "SideWarpIndex"); break; //b
22040 case SCREENDATAUNDERCOMBO: SET_SCREENDATA_VAR_INT32(undercombo, "Undercombo"); break; //w
22041 case SCREENDATAUNDERCSET: SET_SCREENDATA_VAR_BYTE(undercset, "UnderCSet"); break; //b
22042 case SCREENDATACATCHALL: SET_SCREENDATA_VAR_INT32(catchall, "Catchall"); break; //W
22043
22044 case SCREENDATACSENSITIVE: SET_SCREENDATA_VAR_BYTE(csensitive, "CSensitive"); break; //B
22045 case SCREENDATANORESET: SET_SCREENDATA_VAR_INT32(noreset, "NoReset"); break; //W
22046 case SCREENDATANOCARRY: SET_SCREENDATA_VAR_INT32(nocarry, "NoCarry"); break; //W
22047 case SCREENDATALAYERMAP: SET_SCREENDATA_LAYER_INDEX(layermap, "LayerMap", 5); break; //B, 6 OF THESE
22048 case SCREENDATALAYERSCREEN: SET_SCREENDATA_LAYERSCREEN_INDEX(layerscreen, "LayerScreen", 5); break; //B, 6 OF THESE
22049 case SCREENDATALAYEROPACITY: SET_SCREENDATA_LAYER_INDEX(layeropacity, "LayerOpacity", 5); break; //B, 6 OF THESE
22050 case SCREENDATALAYERINVIS:
22051 {
22052 int32_t indx = ri->d[rINDEX] / 10000;
22053 if(indx < 0 || indx > 6 )
22054 {
22055 Z_scripterrlog("Invalid Index passed to Screen->LayerInvisible[]: %d\n", indx);
22056 }
22057 else
22058 {
22059 if(value)
22060 tmpscr->hidelayers |= (1<<indx);
22061 else
22062 tmpscr->hidelayers &= ~(1<<indx);
22063 }
22064 break;
22065 }
22066 case SCREENDATASCRIPTDRAWS:
22067 {
22068 int32_t indx = ri->d[rINDEX] / 10000;
22069 if(indx < 0 || indx > 7 )
22070 {
22071 Z_scripterrlog("Invalid Index passed to Screen->HideScriptLayer[]: %d\n", indx);
22072 }
22073 else
22074 {
22075 if(value)
22076 tmpscr->hidescriptlayers &= ~(1<<indx);
22077 else
22078 tmpscr->hidescriptlayers |= (1<<indx);
22079 }
22080 break;
22081 }
22082
22083 case SCREENDATATILEWARPOVFLAGS:
22084 {
22085 int32_t indx = ri->d[rINDEX] / 10000;
22086 if ( ((unsigned)indx) > 3 )
22087 {
22088 Z_scripterrlog("Invalid index passed to TileWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
22089 }
22090 else
22091 {
22092 if ( value ) tmpscr->tilewarpoverlayflags |= (1<<indx);
22093 else tmpscr->tilewarpoverlayflags &= ~(1<<indx);
22094 }
22095 break;
22096 }
22097
22098 case SCREENDATASIDEWARPOVFLAGS:
22099 {
22100 int32_t indx = ri->d[rINDEX] / 10000;
22101 if ( ((unsigned)indx) > 3 )
22102 {
22103 Z_scripterrlog("Invalid index passed to SideWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
22104 }
22105 else
22106 {
22107 if ( value ) tmpscr->sidewarpoverlayflags |= (1<<indx);
22108 else tmpscr->sidewarpoverlayflags &= ~(1<<indx);
22109 }
22110 break;
22111 }
22112
22113 case SCREENDATATIMEDWARPTICS: SET_SCREENDATA_VAR_INT32(timedwarptics, "TimedWarpTimer"); break; //W
22114 case SCREENDATANEXTMAP: SET_SCREENDATA_VAR_BYTE(nextmap, "NextMap"); break; //B
22115 case SCREENDATANEXTSCREEN: SET_SCREENDATA_VAR_BYTE(nextscr, "NextScreen"); break; //B
22116 128 case SCREENDATASECRETCOMBO: SET_SCREENDATA_VAR_INDEX32(secretcombo, "SecretCombo", 127); break; //W, 128 OF THESE
22117 128 case SCREENDATASECRETCSET: SET_SCREENDATA_BYTE_INDEX(secretcset, "SecretCSet", 127); break; //B, 128 OF THESE
22118 128 case SCREENDATASECRETFLAG: SET_SCREENDATA_BYTE_INDEX(secretflag, "SecretFlags", 127); break; //B, 128 OF THESE
22119 case SCREENDATAVIEWX: break;//SET_SCREENDATA_VAR_INT32(viewX, "ViewX"); break; //W
22120 case SCREENDATAVIEWY: break;//SET_SCREENDATA_VAR_INT32(viewY, "ViewY"); break; //W
22121 case SCREENDATASCREENWIDTH: break;//SET_SCREENDATA_VAR_BYTE(scrWidth, "Width"); break; //B
22122 case SCREENDATASCREENHEIGHT: break;//SET_SCREENDATA_VAR_BYTE(scrHeight, "Height"); break; //B
22123 case SCREENDATAENTRYX:
22124 {
22125 5 int32_t newx = vbound((value/10000),0,255);
22126 5 tmpscr->entry_x = newx;
22127
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if ( get_qr(qr_WRITE_ENTRYPOINTS_AFFECTS_HEROCLASS) )
22128 {
22129 Hero.respawn_x = (zfix)(newx);
22130 }
22131 5 break;
22132 }
22133 case SCREENDATAENTRYY:
22134 {
22135
22136 5 int32_t newy = vbound((value/10000),0,175);
22137 5 tmpscr->entry_y = newy;
22138
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if ( get_qr(qr_WRITE_ENTRYPOINTS_AFFECTS_HEROCLASS) )
22139 {
22140 Hero.respawn_y = (zfix)(newy);
22141 }
22142 5 break; //B
22143 }
22144
22145 case SCREENDATANUMFF:
22146 {
22147 break;
22148 }
22149
22150 case SCREENDATAFFINITIALISED:
22151 {
22152 int32_t indx = ri->d[rINDEX] / 10000;
22153 if (indx < 0 || indx > MAXFFCS-1)
22154 {
22155 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", (indx), "FFCRunning");
22156 break;
22157 }
22158 get_script_engine_data(ScriptType::FFC, indx).initialized = (value/10000) ? true : false;
22159 }
22160 break;
22161
22162 case SCREENDATASCRIPTENTRY: SET_SCREENDATA_VAR_INT32(script_entry, "ScriptEntry"); break; //W
22163 case SCREENDATASCRIPTOCCUPANCY: SET_SCREENDATA_VAR_INT32(script_occupancy, "ScriptOccupancy"); break;//W
22164 case SCREENDATASCRIPTEXIT: SET_SCREENDATA_VAR_INT32(script_exit, "ExitScript"); break; //W
22165 case SCREENDATAOCEANSFX:
22166 {
22167 int32_t v = vbound(value/10000, 0, 255);
22168 if(tmpscr->oceansfx != v)
22169 {
22170 stop_sfx(tmpscr->oceansfx);
22171 tmpscr->oceansfx = v;
22172 cont_sfx(tmpscr->oceansfx);
22173 }
22174 break;
22175 }
22176 case SCREENDATABOSSSFX: SET_SCREENDATA_VAR_BYTE(bosssfx, "BossSFX"); break; //B
22177 case SCREENDATASECRETSFX: SET_SCREENDATA_VAR_BYTE(secretsfx, "SecretSFX"); break; //B
22178 case SCREENDATAHOLDUPSFX: SET_SCREENDATA_VAR_BYTE(holdupsfx, "ItemSFX"); break; //B
22179 case SCREENDATASCREENMIDI:
22180 {
22181 tmpscr->screen_midi = vbound((value / 10000)-(MIDIOFFSET_MAPSCR-MIDIOFFSET_ZSCRIPT),-1,32767);
22182 break;
22183 }
22184 case SCREENDATALENSLAYER: SET_SCREENDATA_VAR_BYTE(lens_layer, "LensLayer"); break; //B, OLD QUESTS ONLY?
22185
22186 case SCREENSIDEWARPID:
22187 {
22188 int32_t indx = ri->d[rINDEX] / 10000; //dir
22189
22190 int32_t new_warp_return = vbound((value / 10000),-1,3); //none, A, B, C, D
22191 if(new_warp_return == -1)
22192 {
22193 tmpscr->flags2 &= ~(1<<indx); //Unset the "Enabled" flag for this dir
22194 tmpscr->sidewarpindex &= ~(3<<(2*indx)); //Clear the dir as well.
22195 }
22196 else
22197 {
22198 tmpscr->flags2 |= 1<<indx; //Set the "Enabled" flag for this dir
22199 tmpscr->sidewarpindex &= ~(3<<(2*indx)); //Clear the dir bits
22200 tmpscr->sidewarpindex |= (new_warp_return<<(2*indx)); //Set the new dir
22201 }
22202
22203 break;
22204 }
22205
22206 case SCREENDATATWARPRETSQR:
22207 {
22208 int32_t indx = ri->d[rINDEX] / 10000;
22209 if ( ((unsigned)indx) > 3)
22210 {
22211 Z_scripterrlog("Invalid Array Index passed to Screen->TileWarpReturnSquare[]: %d\n", indx);
22212 }
22213 else
22214 {
22215 int32_t wrindex = vbound(value/10000, 0, 3);
22216 tmpscr->warpreturnc = (tmpscr->warpreturnc&~(3<<(indx*2))) | (wrindex<<(indx*2));
22217 }
22218 break;
22219 }
22220
22221 //
22222 case SCREENDATASWARPRETSQR:
22223 {
22224
22225 int32_t indx = ri->d[rINDEX] / 10000;
22226 if ( ((unsigned)indx) > 3)
22227 {
22228 Z_scripterrlog("Invalid Array Index passed to Screen->SideWarpReturnSquare[]: %d\n", indx);
22229 }
22230 else
22231 {
22232 int32_t wrindex = vbound(value/10000, 0, 3);
22233 tmpscr->warpreturnc = (tmpscr->warpreturnc&~(3<<(8+(indx*2)))) | (wrindex<<(8+(indx*2)));
22234 }
22235 break;
22236 }
22237
22238
22239 case SCREENDATAFLAGS:
22240 {
22241 int32_t flagid = (ri->d[rINDEX])/10000;
22242 //bool valtrue = ( value ? 10000 : 0);
22243 switch(flagid)
22244 {
22245 case 0: tmpscr->flags = (value / 10000); break;
22246 case 1: tmpscr->flags2 = (value / 10000); break;
22247 case 2: tmpscr->flags3 = (value / 10000); break;
22248 case 3: tmpscr->flags4 = (value / 10000); break;
22249 case 4: tmpscr->flags5 = (value / 10000); break;
22250 case 5: tmpscr->flags6 = (value / 10000); break;
22251 case 6: tmpscr->flags7 = (value / 10000); break;
22252 case 7: tmpscr->flags8 = (value / 10000); break;
22253 case 8: tmpscr->flags9 = (value / 10000); break;
22254 case 9: tmpscr->flags10 = (value / 10000); break;
22255 default:
22256 {
22257 Z_scripterrlog("Invalid index passed to mapdata->flags[]: %d\n", flagid);
22258 break;
22259
22260 }
22261 }
22262 break;
22263 //GET_SCREENDATA_BYTE_INDEX //B, 11 OF THESE, flags, flags2-flags10
22264 }
22265
22266
22267 //These use the same method as SetScreenD
22268 case SCREENWIDTH:
22269 // FFScript::set_screenWidth(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22270 break;
22271
22272 case SCREENHEIGHT:
22273 // FFScript::set_screenHeight(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22274 break;
22275
22276 case SCREENVIEWX:
22277 // FFScript::set_screenViewX(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22278 break;
22279
22280 case SCREENVIEWY:
22281 // FFScript::set_screenViewY(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22282 break;
22283
22284 case SCREENGUY:
22285 FFScript::set_screenGuy(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22286 break;
22287
22288 case SCREENSTRING:
22289 {
22290 FFScript::set_screenString(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22291 //should this be either
22292 //set_screenString(&TheMaps[((ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)])-1), value/10000);
22293 //or
22294 //set_screenString(&TheMaps[((ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)])-+1), value/10000);
22295 Z_message("Map ref is: %d\n",((ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)));
22296 }
22297 break;
22298
22299 case SCREENROOM:
22300 FFScript::set_screenRoomtype(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22301 break;
22302
22303 case SCREENENTX:
22304 FFScript::set_screenEntryX(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22305 break;
22306
22307 case SCREENENTY:
22308 FFScript::set_screenEntryY(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22309 break;
22310
22311 case SCREENITEM:
22312 FFScript::set_screenitem(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22313 break;
22314
22315 case SCREENUNDCMB:
22316 FFScript::set_screenundercombo(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22317 break;
22318
22319 case SCREENUNDCST:
22320 FFScript::set_screenundercset(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22321 break;
22322
22323 case SCREENCATCH:
22324 FFScript::set_screenatchall(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
22325 break;
22326
22327 //These use the method of SetScreenEnemy
22328
22329
22330 //SetScreenLayerOpacity(int32_t map, int32_t scr, int32_t layer, int32_t v)
22331 case SETSCREENLAYOP:
22332 {
22333 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
22334 int32_t scrn = ri->d[rEXP1] / 10000;
22335 int32_t index = ri->d[rINDEX] / 10000;
22336 int32_t nn = ri->d[rEXP2]/10000;
22337
22338 if(BC::checkMapID(map, "Game->SetScreenLayerOpacity(...map...)") != SH::_NoError ||
22339 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenLayerOpacity(...screen...)") != SH::_NoError ||
22340 BC::checkBounds(index, 0, 9, "Game->SetScreenLayerOpacity(...index...)") != SH::_NoError)
22341 return;
22342
22343 FFScript::set_screenlayeropacity(&TheMaps[map * MAPSCRS + scrn], index, nn);
22344 }
22345 break;
22346
22347 case SETSCREENSECCMB:
22348 {
22349 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
22350 int32_t scrn = ri->d[rEXP1] / 10000;
22351 int32_t index = ri->d[rINDEX] / 10000;
22352 int32_t nn = ri->d[rEXP2]/10000;
22353
22354 if(BC::checkMapID(map, "Game->SetScreenSecretCombo(...map...)") != SH::_NoError ||
22355 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenSecretCombo(...screen...)") != SH::_NoError ||
22356 BC::checkBounds(index, 0, 9, "Game->SetScreenSecretCombo(...index...)") != SH::_NoError)
22357 return;
22358
22359 FFScript::set_screensecretcombo(&TheMaps[map * MAPSCRS + scrn], index, nn);
22360 }
22361 break;
22362
22363 case SETSCREENSECCST:
22364 {
22365 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
22366 int32_t scrn = ri->d[rEXP1] / 10000;
22367 int32_t index = ri->d[rINDEX] / 10000;
22368 int32_t nn = ri->d[rEXP2]/10000;
22369
22370 if(BC::checkMapID(map, "Game->SetScreenSecretCSet(...map...)") != SH::_NoError ||
22371 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenSecretCSet(...screen...)") != SH::_NoError ||
22372 BC::checkBounds(index, 0, 9, "Game->SetScreenSecretCSet(...index...)") != SH::_NoError)
22373 return;
22374
22375 FFScript::set_screensecretcset(&TheMaps[map * MAPSCRS + scrn], index, nn);
22376 }
22377 break;
22378
22379 case SETSCREENSECFLG:
22380 {
22381 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
22382 int32_t scrn = ri->d[rEXP1] / 10000;
22383 int32_t index = ri->d[rINDEX] / 10000;
22384 int32_t nn = ri->d[rEXP2]/10000;
22385
22386 if(BC::checkMapID(map, "Game->SetScreenSecretFlag(...map...)") != SH::_NoError ||
22387 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenSecretFlag(...screen...)") != SH::_NoError ||
22388 BC::checkBounds(index, 0, 9, "Game->SetScreenSecretFlag(...index...)") != SH::_NoError)
22389 return;
22390
22391 FFScript::set_screensecretflag(&TheMaps[map * MAPSCRS + scrn], index, nn);
22392 }
22393 break;
22394
22395 case SETSCREENLAYMAP:
22396 {
22397 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
22398 int32_t scrn = ri->d[rEXP1] / 10000;
22399 int32_t index = ri->d[rINDEX] / 10000;
22400 int32_t nn = ri->d[rEXP2]/10000;
22401
22402 if(BC::checkMapID(map, "Game->SetScreenLayerMap(...map...)") != SH::_NoError ||
22403 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenLayerMap(...screen...)") != SH::_NoError ||
22404 BC::checkBounds(index, 0, 9, "Game->SetScreenLayerMap(...index...)") != SH::_NoError)
22405 return;
22406
22407 FFScript::set_screenlayermap(&TheMaps[map * MAPSCRS + scrn], index, nn);
22408 }
22409 break;
22410
22411 case SETSCREENLAYSCR:
22412 {
22413 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
22414 int32_t scrn = ri->d[rEXP1] / 10000;
22415 int32_t index = ri->d[rINDEX] / 10000;
22416 int32_t nn = ri->d[rEXP2]/10000;
22417
22418 if(BC::checkMapID(map, "Game->SetScreenLayerScreen(...map...)") != SH::_NoError ||
22419 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenLayerScreen(...screen...)") != SH::_NoError ||
22420 BC::checkBounds(index, 0, 9, "Game->SetScreenLayerScreen(...index...)") != SH::_NoError)
22421 return;
22422
22423 FFScript::set_screenlayerscreen(&TheMaps[map * MAPSCRS + scrn], index, nn);
22424 }
22425 break;
22426
22427 case SETSCREENPATH:
22428 {
22429 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
22430 int32_t scrn = ri->d[rEXP1] / 10000;
22431 int32_t index = ri->d[rINDEX] / 10000;
22432 int32_t nn = ri->d[rEXP2]/10000;
22433
22434 if(BC::checkMapID(map, "Game->SetScreenPath(...map...)") != SH::_NoError ||
22435 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenPath(...screen...)") != SH::_NoError ||
22436 BC::checkBounds(index, 0, 9, "Game->SetScreenPath(...index...)") != SH::_NoError)
22437 return;
22438
22439 FFScript::set_screenpath(&TheMaps[map * MAPSCRS + scrn], index, nn);
22440 }
22441 break;
22442
22443 case SETSCREENWARPRX:
22444 {
22445 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
22446 int32_t scrn = ri->d[rEXP1] / 10000;
22447 int32_t index = ri->d[rINDEX] / 10000;
22448 int32_t nn = ri->d[rEXP2]/10000;
22449
22450 if(BC::checkMapID(map, "Game->SetScreenWarpReturnX(...map...)") != SH::_NoError ||
22451 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenWarpReturnX(...screen...)") != SH::_NoError ||
22452 BC::checkBounds(index, 0, 9, "Game->SetScreenWarpReturnX(...index...)") != SH::_NoError)
22453 return;
22454
22455 FFScript::set_screenwarpReturnX(&TheMaps[map * MAPSCRS + scrn], index, nn);
22456 }
22457 break;
22458
22459 case SETSCREENWARPRY:
22460 {
22461 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
22462 int32_t scrn = ri->d[rEXP1] / 10000;
22463 int32_t index = ri->d[rINDEX] / 10000;
22464 int32_t nn = ri->d[rEXP2]/10000;
22465
22466 if(BC::checkMapID(map, "Game->SetScreenWarpReturnY(...map...)") != SH::_NoError ||
22467 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenWarpReturnY(...screen...)") != SH::_NoError ||
22468 BC::checkBounds(index, 0, 9, "Game->SetScreenWarpReturnY(...index...)") != SH::_NoError)
22469 return;
22470
22471 FFScript::set_screenwarpReturnY(&TheMaps[map * MAPSCRS + scrn], index, nn);
22472 }
22473 break;
22474
22475 case SDD:
22476 {
22477 {
22478
2/2
✓ Branch 0 taken 14236 times.
✓ Branch 1 taken 41 times.
14277 int32_t di2 = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
22479 14277 FFScript::set_screen_d(di2, ri->d[rINDEX]/10000, value);
22480 14277 break;
22481 }
22482 }
22483
22484 case GDD:
22485 al_trace("GDD");
22486 game->global_d[ri->d[rINDEX]/10000]=value;
22487 break;
22488
22489 case SDDD:
22490 27297 FFScript::set_screen_d((ri->d[rINDEX])/10000 + ((get_currdmap())<<7), ri->d[rINDEX2]/10000, value);
22491 27297 break;
22492
22493 case SDDDD:
22494 531 FFScript::set_screen_d(ri->d[rINDEX2]/10000 + ((ri->d[rINDEX]/10000)<<7), ri->d[rEXP1]/10000, value);
22495 531 break;
22496
22497 case SCREENINITD:
22498 tmpscr->screeninitd[ri->d[rINDEX]/10000] = value;
22499 break;
22500
22501 case SCREENSCRIPT:
22502 {
22503 FFScript::deallocateAllScriptOwned(ScriptType::Screen, 0);
22504
22505 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
22506 {
22507 for(int32_t q=0; q<8; q++)
22508 tmpscr->screeninitd[q] = 0;
22509 }
22510 FFCore.ref(ScriptType::Screen, 0).Clear();
22511 tmpscr->script=vbound(value/10000, 0, NUMSCRIPTSCREEN-1);
22512 break;
22513 }
22514
22515 case MAPDATAINITD:
22516 tmpscr->screeninitd[ri->d[rINDEX]/10000]=value;
22517 break;
22518
22519 case SCRDOORD:
22520 4 tmpscr->door[ri->d[rINDEX]/10000]=value/10000;
22521 4 putdoor(scrollbuf,0,ri->d[rINDEX]/10000,value/10000,true,true);
22522 4 break;
22523
22524 case LIT:
22525 900 naturaldark = !value;
22526 900 lighting(false, false);
22527 900 break;
22528
22529 case WAVY:
22530 7214 wavy=value/10000;
22531 7214 break;
22532
22533 case QUAKE:
22534 3579 quakeclk=value/10000;
22535 3579 break;
22536
22537 case ROOMTYPE:
22538 tmpscr->room=value/10000; break; //this probably doesn't work too well...
22539
22540 case ROOMDATA:
22541 11 tmpscr->catchall=value/10000;
22542 11 break;
22543
22544 case PUSHBLOCKLAYER:
22545 mblock2.blockLayer=vbound(value/10000, 0, 6);
22546 break;
22547
22548 case PUSHBLOCKCOMBO:
22549 mblock2.bcombo=value/10000;
22550 break;
22551
22552 case PUSHBLOCKCSET:
22553 mblock2.cs=value/10000;
22554 mblock2.oldcset=value/10000;
22555 break;
22556
22557 case UNDERCOMBO:
22558 tmpscr->undercombo=value/10000;
22559 break;
22560
22561 case UNDERCSET:
22562 tmpscr->undercset=value/10000;
22563 break;
22564
22565
22566 case DEBUGGDR:
22567 {
22568 int32_t a = vbound(ri->d[rINDEX]/10000,0,15);
22569 game->global_d[a] = value / 10000;;
22570 break;
22571 }
22572
22573 case DEBUGSP:
22574 SH::write_stack(ri->sp,vbound((value / 10000),0,MAX_SCRIPT_REGISTERS-1));
22575 break;
22576
22577 case DEBUGREFFFC:
22578 ri->ffcref = vbound((value / 10000),1,MAXFFCS-1);
22579 break;
22580
22581 case DEBUGREFITEM:
22582 ri->itemref = vbound((value / 10000),0,255);
22583 break;
22584
22585 case DEBUGREFITEMDATA:
22586 ri->idata = vbound((value / 10000),0,255);
22587 break;
22588
22589 case DEBUGREFLWEAPON:
22590 ri->lwpn = vbound((value / 10000),0,255);
22591 break;
22592
22593 case DEBUGREFEWEAPON:
22594 ri->ewpn = vbound((value / 10000),0,255);
22595 break;
22596
22597 case DEBUGREFNPC:
22598 ri->guyref = vbound((value / 10000),0,255);
22599 break;
22600
22601
22602 //Game Over Screen
22603 case SETGAMEOVERELEMENT:
22604 {
22605 17 int32_t colour = value/10000;
22606 17 int32_t index = ri->d[rINDEX]/10000;
22607 17 index = vbound(index,0,SAVESC_LAST-1);
22608 // zprint("GameOverScreen Index,Value: %d,%ld/n",index,colour);
22609 17 SetSaveScreenSetting(index,colour);
22610 17 break;
22611 }
22612
22613 case SETGAMEOVERSTRING:
22614 {
22615 int32_t arrayptr = value/10000;
22616 int32_t index = ri->d[rINDEX]/10000;
22617 index = vbound(index,0,SAVESC_END-1);
22618 string filename_str;
22619 ArrayH::getString(arrayptr, filename_str, 73);
22620 ChangeSubscreenText(index,filename_str.c_str());
22621 break;
22622 }
22623
22624 ///----------------------------------------------------------------------------------------------------//
22625 //New Datatype Variables
22626
22627 ///----------------------------------------------------------------------------------------------------//
22628 //spritedata sp-> Variables
22629 case SPRITEDATATILE: SET_SPRITEDATA_VAR_INT(tile, "Tile"); break;
22630 case SPRITEDATAMISC: SET_SPRITEDATA_VAR_BYTE(misc, "Misc"); break;
22631 case SPRITEDATACSETS:
22632 {
22633 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
22634 {
22635 Z_scripterrlog("Invalid Sprite ID passed to spritedata->CSet: %d\n", (ri->spritesref*10000));
22636 }
22637 else
22638 {
22639 wpnsbuf[ri->spritesref].csets &= 0xF0;
22640 wpnsbuf[ri->spritesref].csets |= vbound((value / 10000),0,15);
22641 }
22642 break;
22643 }
22644 case SPRITEDATAFLCSET:
22645 {
22646 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
22647 {
22648 Z_scripterrlog("Invalid Sprite ID passed to spritedata->FlashCSet: %d\n", (ri->spritesref*10000));
22649 }
22650 else
22651 {
22652 wpnsbuf[ri->spritesref].csets &= 0x0F;
22653 wpnsbuf[ri->spritesref].csets |= vbound((value / 10000),0,15)<<4;
22654 }
22655 break;
22656 }
22657 case SPRITEDATAFRAMES: SET_SPRITEDATA_VAR_BYTE(frames, "Frames"); break;
22658 case SPRITEDATASPEED: SET_SPRITEDATA_VAR_BYTE(speed, "Speed"); break;
22659 case SPRITEDATATYPE: SET_SPRITEDATA_VAR_BYTE(type, "Type"); break;
22660 case SPRITEDATAFLAGS:
22661 {
22662 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
22663 {
22664 Z_scripterrlog("Invalid Sprite ID passed to spritedata->Flags[]: %d\n", (ri->spritesref*10000));
22665 break;
22666 }
22667 int32_t index = ri->d[rINDEX]/10000;
22668 if(unsigned(index) >= 5)
22669 {
22670 Z_scripterrlog("Invalid index passed to spritedata->Flags[]: %d\n", index);
22671 break;
22672 }
22673 SETFLAG(wpnsbuf[ri->spritesref].misc, 1<<index, value);
22674 break;
22675 }
22676
22677 ///----------------------------------------------------------------------------------------------------//
22678 //mapdata m-> Variables
22679 //mapdata m-> Variables
22680
22681 #define SET_MAPDATA_VAR_INT32(member, str) \
22682 { \
22683 if (mapscr *m = GetMapscr(ri->mapsref)) \
22684 { \
22685 m->member = vbound((value / 10000),-214747,214747); \
22686 } \
22687 else \
22688 { \
22689 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22690 } \
22691 break; \
22692 } \
22693
22694 #define SET_MAPDATA_VAR_INT16(member, str) \
22695 { \
22696 if (mapscr *m = GetMapscr(ri->mapsref)) \
22697 { \
22698 m->member = vbound((value / 10000),0,32767); \
22699 } \
22700 else \
22701 { \
22702 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22703 } \
22704 break; \
22705 } \
22706
22707 #define SET_MAPDATA_VAR_BYTE(member, str) \
22708 { \
22709 if (mapscr *m = GetMapscr(ri->mapsref)) \
22710 { \
22711 m->member = vbound((value / 10000),0,255); \
22712 } \
22713 else \
22714 { \
22715 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22716 } \
22717 break; \
22718 } \
22719
22720 #define SET_MAPDATA_VAR_INDEX32(member, str, indexbound) \
22721 { \
22722 int32_t indx = ri->d[rINDEX] / 10000; \
22723 if(indx < 0 || indx > indexbound ) \
22724 { \
22725 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
22726 } \
22727 else if (mapscr *m = GetMapscr(ri->mapsref)) \
22728 { \
22729 m->member[indx] = vbound((value / 10000),-214747,214747); \
22730 } \
22731 else \
22732 { \
22733 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22734 } \
22735 break; \
22736 } \
22737
22738 #define SET_MAPDATA_VAR_INDEX16(member, str, indexbound) \
22739 { \
22740 int32_t indx = ri->d[rINDEX] / 10000; \
22741 if(indx < 0 || indx > indexbound ) \
22742 { \
22743 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
22744 } \
22745 else if (mapscr *m = GetMapscr(ri->mapsref)) \
22746 { \
22747 m->member[indx] = vbound((value / 10000),-32767,32767); \
22748 } \
22749 else \
22750 { \
22751 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22752 } \
22753 break; \
22754 } \
22755
22756 #define SET_MAPDATA_BYTE_INDEX(member, str, indexbound) \
22757 { \
22758 int32_t indx = ri->d[rINDEX] / 10000; \
22759 if(indx < 0 || indx > indexbound ) \
22760 { \
22761 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
22762 } \
22763 else if (mapscr *m = GetMapscr(ri->mapsref)) \
22764 { \
22765 m->member[indx] = vbound((value / 10000),0,255); \
22766 } \
22767 else \
22768 { \
22769 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22770 } \
22771 break; \
22772 }\
22773
22774 #define SET_MAPDATA_LAYER_INDEX(member, str, indexbound) \
22775 { \
22776 int32_t indx = ri->d[rINDEX] / 10000; \
22777 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
22778 if(indx < 1 || indx > indexbound ) \
22779 { \
22780 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
22781 } \
22782 else if (mapscr *m = GetMapscr(ri->mapsref)) \
22783 { \
22784 m->member[indx-1] = vbound((value / 10000),0,255); \
22785 } \
22786 else \
22787 { \
22788 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22789 } \
22790 break; \
22791 } \
22792
22793 #define SET_MAPDATA_LAYERSCREEN_INDEX(member, str, indexbound) \
22794 { \
22795 int32_t indx = ri->d[rINDEX] / 10000; \
22796 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
22797 int32_t scrn_id = value/10000; \
22798 if(indx < 1 || indx > indexbound ) \
22799 { \
22800 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
22801 } \
22802 else if ( scrn_id > MAPSCRS ) \
22803 { \
22804 Z_scripterrlog("Script attempted to use a mapdata->LayerScreen[%d].\n",scrn_id); \
22805 Z_scripterrlog("Valid Screen values are (0) through (%d).\n",MAPSCRS); \
22806 } \
22807 else if (mapscr *m = GetMapscr(ri->mapsref)) \
22808 { \
22809 m->member[indx-1] = vbound((scrn_id),0,MAPSCRS); \
22810 } \
22811 else \
22812 { \
22813 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22814 } \
22815 break; \
22816 }\
22817
22818 #define SET_MAPDATA_BOOL_INDEX(member, str, indexbound) \
22819 { \
22820 int32_t indx = ri->d[rINDEX] / 10000; \
22821 if(indx < 0 || indx > indexbound ) \
22822 { \
22823 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
22824 } \
22825 else if (mapscr *m = GetMapscr(ri->mapsref)) \
22826 { \
22827 m->member[indx] =( (value/10000) ? 1 : 0 ); \
22828 } \
22829 else \
22830 { \
22831 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22832 } \
22833 break; \
22834 } \
22835
22836 #define SET_FFC_MAPDATA_BOOL_INDEX(member, str, indexbound) \
22837 { \
22838 int32_t indx = ri->d[rINDEX] / 10000; \
22839 if(indx < 0 || indx > indexbound ) \
22840 { \
22841 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
22842 } \
22843 else if (mapscr *m = GetMapscr(ri->mapsref)) \
22844 { \
22845 m->ffcs[indx].member =( (value/10000) ? 1 : 0 ); \
22846 } \
22847 else \
22848 { \
22849 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22850 } \
22851 break; \
22852 } \
22853
22854 #define SET_MAPDATA_FLAG(member, str) \
22855 { \
22856 int32_t flag = (value/10000); \
22857 if (mapscr *m = GetMapscr(ri->mapsref)) \
22858 { \
22859 if ( flag != 0 ) \
22860 { \
22861 m->member|=flag; \
22862 } \
22863 else m->.member|= ~flag; \
22864 } \
22865 else \
22866 { \
22867 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
22868 } \
22869 break; \
22870 } \
22871
22872 #define SET_MAPDATA_FFCPOS_INDEX32(member, str, indexbound) \
22873 { \
22874 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
22875 if(indx < 0 || indx > indexbound ) \
22876 { \
22877 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
22878 } \
22879 else if (mapscr *m = GetMapscr(ri->mapsref)) \
22880 { \
22881 m->ffcs[indx].member = zslongToFix(value); \
22882 } \
22883 else \
22884 { \
22885 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
22886 } \
22887 break; \
22888 } \
22889
22890 #define SET_MAPDATA_FFC_INDEX32(member, str, indexbound) \
22891 { \
22892 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
22893 if(indx < 0 || indx > indexbound ) \
22894 { \
22895 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
22896 } \
22897 else if (mapscr *m = GetMapscr(ri->mapsref)) \
22898 { \
22899 m->ffcs[indx].member = value/10000; \
22900 } \
22901 else \
22902 { \
22903 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
22904 } \
22905 break; \
22906 } \
22907
22908 #define SET_MAPDATA_FFC_INDEX_VBOUND(member, str, indexbound, min, max) \
22909 { \
22910 int32_t v = value/10000; \
22911 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
22912 if(indx < 0 || indx > indexbound ) \
22913 { \
22914 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
22915 } \
22916 else if(v < min || v > max ) \
22917 { \
22918 Z_scripterrlog("Invalid value assigned to mapdata->%s[]: %d\n", (indx+1), str); \
22919 } \
22920 else if (mapscr *m = GetMapscr(ri->mapsref)) \
22921 { \
22922 m->ffcs[indx].member = v; \
22923 } \
22924 else \
22925 { \
22926 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
22927 } \
22928 break; \
22929 } \
22930
22931 case MAPDATAVALID: SET_MAPDATA_VAR_BYTE(valid, "Valid"); break; //b
22932 case MAPDATAGUY: SET_MAPDATA_VAR_BYTE(guy, "Guy"); break; //b
22933 case MAPDATASTRING: SET_MAPDATA_VAR_INT32(str, "String"); break; //w
22934 case MAPDATAROOM: SET_MAPDATA_VAR_BYTE(room, "RoomType"); break; //b
22935 case MAPDATAITEM:
22936 {
22937 if (mapscr *m = GetMapscr(ri->mapsref))
22938 {
22939 auto v = vbound((value / 10000),-1,255);
22940 if(v > -1)
22941 m->item = v;
22942 m->hasitem = v > -1;
22943 }
22944 else
22945 {
22946 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Item");
22947 }
22948 break;
22949 }
22950 case MAPDATAHASITEM: SET_MAPDATA_VAR_BYTE(hasitem, "HasItem"); break; //b
22951 case MAPDATATILEWARPTYPE: SET_MAPDATA_BYTE_INDEX(tilewarptype, "TileWarpType", 3); break; //b, 4 of these
22952 //case MAPDATATILEWARPOVFLAGS: SET_MAPDATA_VAR_BYTE(tilewarpoverlayflags, "TileWarpOverlayFlags"); break; //b, tilewarpoverlayflags
22953 case MAPDATADOORCOMBOSET: SET_MAPDATA_VAR_INT32(door_combo_set, "DoorComboSet"); break; //w
22954 case MAPDATAWARPRETX: SET_MAPDATA_BYTE_INDEX(warpreturnx, "WarpReturnX", 3); break; //b, 4 of these
22955 case MAPDATAWARPRETY: SET_MAPDATA_BYTE_INDEX(warpreturny, "WarpReturnY", 3); break; //b, 4 of these
22956 case MAPDATAWARPRETURNC: SET_MAPDATA_VAR_INT32(warpreturnc, "WarpReturnC"); break; //w
22957 case MAPDATASTAIRX: SET_MAPDATA_VAR_BYTE(stairx, "StairsX"); break; //b
22958 case MAPDATASTAIRY: SET_MAPDATA_VAR_BYTE(stairy, "StairsY"); break; //b
22959 case MAPDATAITEMX: SET_MAPDATA_VAR_BYTE(itemx, "ItemX"); break; //itemx
22960 case MAPDATAITEMY: SET_MAPDATA_VAR_BYTE(itemy, "ItemY"); break; //itemy
22961 case MAPDATACOLOUR: SET_MAPDATA_VAR_INT32(color, "CSet"); break; //w
22962 case MAPDATAENEMYFLAGS: SET_MAPDATA_VAR_BYTE(enemyflags, "EnemyFlags"); break; //b
22963 case MAPDATADOOR: SET_MAPDATA_BYTE_INDEX(door, "Door", 3); break; //b, 4 of these
22964 case MAPDATATILEWARPDMAP: SET_MAPDATA_VAR_INDEX32(tilewarpdmap, "TileWarpDMap", 3); break; //w, 4 of these
22965 case MAPDATATILEWARPSCREEN: SET_MAPDATA_BYTE_INDEX(tilewarpscr, "TileWarpScreen", 3); break; //b, 4 of these
22966 case MAPDATAEXITDIR: SET_MAPDATA_VAR_BYTE(exitdir, "ExitDir"); break; //b
22967 case MAPDATAENEMY:
22968 {
22969 int32_t indx = (ri->d[rINDEX] / 10000);
22970 int32_t enemyid = value/10000;
22971 if( ((unsigned)indx) > 9 )
22972 {
22973 Z_scripterrlog("Invalid Index passed to mapdata->%s: %d\n", "Enemy[]", (indx));
22974 }
22975 else if ( ((unsigned)enemyid) > MAXGUYS )
22976 {
22977 Z_scripterrlog("Invaid enemy ID (%d) passed to Mapdata->%s.", enemyid,"Enemy[]");
22978 }
22979 else if (mapscr *m = GetMapscr(ri->mapsref))
22980 {
22981 m->enemy[indx] = enemyid;
22982 }
22983 else
22984 {
22985 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","Enemy[]");
22986 }
22987 break;
22988 }
22989 //case MAPDATAENEMY: SET_MAPDATA_VAR_INDEX32(enemy, "Enemy", 9); break; //w, 10 of these
22990 case MAPDATAPATTERN: SET_MAPDATA_VAR_BYTE(pattern, "Pattern"); break; //b
22991 case MAPDATASIDEWARPTYPE: SET_MAPDATA_BYTE_INDEX(sidewarptype, "SideWarpType", 3); break; //b, 4 of these
22992 //case MAPDATASIDEWARPOVFLAGS: SET_MAPDATA_VAR_BYTE(sidewarpoverlayflags, "SideWarpOverlayFlags"); break; //b
22993 case MAPDATAWARPARRIVALX: SET_MAPDATA_VAR_BYTE(warparrivalx, "WarpArrivalX"); break; //b
22994 case MAPDATAWARPARRIVALY: SET_MAPDATA_VAR_BYTE(warparrivaly, "WarpArrivalY"); break; //b
22995 case MAPDATAPATH: SET_MAPDATA_BYTE_INDEX(path, "MazePath", 3); break; //b, 4 of these
22996 case MAPDATASIDEWARPSC: SET_MAPDATA_BYTE_INDEX(sidewarpscr, "SideWarpScreen", 3); break; //b, 4 of these
22997 case MAPDATAINITDARRAY:
22998 {
22999
23000 if (mapscr *m = GetMapscr(ri->mapsref))
23001 {
23002 m->screeninitd[ri->d[rINDEX]/10000] = value;
23003 }
23004 else
23005 {
23006 Z_scripterrlog("Script attempted to use a mapdata->InitD[%d] on a pointer that is uninitialised\n",ri->d[rINDEX]/10000);
23007 }
23008 break;
23009 }
23010
23011
23012 case MAPDATALAYERINVIS:
23013 {
23014 int32_t indx = ri->d[rINDEX] / 10000;
23015 if(indx < 0 || indx > 6 )
23016 {
23017 Z_scripterrlog("Invalid Index passed to mapdata->LayerInvisible[]: %d\n", indx);
23018 }
23019 else
23020 {
23021
23022 if (mapscr *m = GetMapscr(ri->mapsref))
23023 {
23024 if(value)
23025 {
23026 tmpscr->hidelayers |= (1<<indx);
23027 }
23028 else
23029 {
23030 tmpscr->hidelayers &= ~(1<<indx);
23031 }
23032 }
23033 else
23034 {
23035 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","LayerInvisible");
23036 }
23037 }
23038 break;
23039 }
23040 case MAPDATASCRIPTDRAWS:
23041 {
23042 int32_t indx = ri->d[rINDEX] / 10000;
23043 if(indx < 0 || indx > 7 )
23044 {
23045 Z_scripterrlog("Invalid Index passed to mapdata->DisableScriptDraw[]: %d\n", indx);
23046 }
23047 else
23048 {
23049 if (mapscr *m = GetMapscr(ri->mapsref))
23050 {
23051 if(value)
23052 {
23053 tmpscr->hidescriptlayers &= ~(1<<indx);
23054 }
23055 else
23056 {
23057 tmpscr->hidescriptlayers |= (1<<indx);
23058 }
23059 }
23060 else
23061 {
23062 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","DisableScriptDraw");
23063 }
23064 }
23065 break;
23066 }
23067
23068 case MAPDATATILEWARPOVFLAGS:
23069 {
23070 int32_t indx = ri->d[rINDEX] / 10000;
23071 if ( ((unsigned)indx) > 3 )
23072 {
23073 Z_scripterrlog("Invalid index passed to TileWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
23074 }
23075 else if (mapscr *m = GetMapscr(ri->mapsref))
23076 {
23077 if ( value ) m->tilewarpoverlayflags |= (1<<indx);
23078 else m->tilewarpoverlayflags &= ~(1<<indx);
23079 }
23080 else
23081 {
23082 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","NumFFCs[]");
23083 }
23084 break;
23085 }
23086
23087 case MAPDATASIDEWARPOVFLAGS:
23088 {
23089 int32_t indx = ri->d[rINDEX] / 10000;
23090 if ( ((unsigned)indx) > 3 )
23091 {
23092 Z_scripterrlog("Invalid index passed to SideWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
23093 }
23094 else if (mapscr *m = GetMapscr(ri->mapsref))
23095 {
23096 if ( value ) m->sidewarpoverlayflags |= (1<<indx);
23097 else m->sidewarpoverlayflags &= ~(1<<indx);
23098 }
23099 else
23100 {
23101 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","NumFFCs[]");
23102 }
23103 break;
23104 }
23105
23106 case MAPDATASIDEWARPDMAP: SET_MAPDATA_VAR_INDEX32(sidewarpdmap, "SideWarpDMap", 3); break; //w, 4 of these
23107 case MAPDATASIDEWARPINDEX: SET_MAPDATA_VAR_BYTE(sidewarpindex, "SideWarpIndex"); break; //b
23108 case MAPDATAUNDERCOMBO: SET_MAPDATA_VAR_INT32(undercombo, "UnderCombo"); break; //w
23109 case MAPDATAUNDERCSET: SET_MAPDATA_VAR_BYTE(undercset, "UnderCSet"); break; //b
23110 case MAPDATACATCHALL: SET_MAPDATA_VAR_INT32(catchall, "Catchall"); break; //W
23111
23112 case MAPDATACSENSITIVE: SET_MAPDATA_VAR_BYTE(csensitive, "CSensitive"); break; //B
23113 case MAPDATANORESET: SET_MAPDATA_VAR_INT32(noreset, "NoReset"); break; //W
23114 case MAPDATANOCARRY: SET_MAPDATA_VAR_INT32(nocarry, "NoCarry"); break; //W
23115 //! Layer arrays should be a size of 7, and return the current screen / map / and OP_OPAQUE
23116 //! if you try to read 0, so that they correspond to actual layer IDs.
23117 //!
23118 case MAPDATALAYERMAP: SET_MAPDATA_LAYER_INDEX(layermap, "LayerMap", 6); break; //B, 6 OF THESE
23119 case MAPDATALAYERSCREEN: SET_MAPDATA_LAYERSCREEN_INDEX(layerscreen, "LayerScreen", 6); break; //B, 6 OF THESE
23120 case MAPDATALAYEROPACITY: SET_MAPDATA_LAYER_INDEX(layeropacity, "LayerOpacity", 6); break; //B, 6 OF THESE
23121 case MAPDATATIMEDWARPTICS: SET_MAPDATA_VAR_INT32(timedwarptics, "TimedWarpTimer"); break; //W
23122 case MAPDATANEXTMAP: SET_MAPDATA_VAR_BYTE(nextmap, "NextMap"); break; //B
23123 case MAPDATANEXTSCREEN: SET_MAPDATA_VAR_BYTE(nextscr, "NextScreen"); break; //B
23124 case MAPDATASECRETCOMBO: SET_MAPDATA_VAR_INDEX32(secretcombo, "SecretCombo", 127); break; //W, 128 OF THESE
23125 case MAPDATASECRETCSET: SET_MAPDATA_BYTE_INDEX(secretcset, "SecretCSet", 127); break; //B, 128 OF THESE
23126 case MAPDATASECRETFLAG: SET_MAPDATA_BYTE_INDEX(secretflag, "SecretFlags", 127); break; //B, 128 OF THESE
23127 case MAPDATAVIEWX: break;//SET_MAPDATA_VAR_INT32(viewX, "ViewX"); break; //W
23128 case MAPDATASCRIPT:
23129 {
23130 if (mapscr *m = GetMapscr(ri->mapsref))
23131 {
23132 if(ri->mapsref == MAPSCR_TEMP0) //This mapsref references tmpscr, so can reference a running script!
23133 {
23134 FFScript::deallocateAllScriptOwned(ScriptType::Screen, 0);
23135
23136 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
23137 {
23138 for(int32_t q=0; q<8; q++)
23139 tmpscr->screeninitd[q] = 0;
23140 }
23141
23142 FFCore.ref(ScriptType::Screen, 0).Clear();
23143 }
23144 m->script=vbound(value/10000, 0, NUMSCRIPTSCREEN-1);
23145 }
23146 else
23147 {
23148 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Script");
23149 }
23150 break;
23151
23152 }
23153 case MAPDATAVIEWY: break;//SET_MAPDATA_VAR_INT32(viewY, "ViewY"); break; //W
23154 case MAPDATASCREENWIDTH: break;//SET_MAPDATA_VAR_BYTE(scrWidth, "Width"); break; //B
23155 case MAPDATASCREENHEIGHT: break;//SET_MAPDATA_VAR_BYTE(scrHeight, "Height"); break; //B
23156 case MAPDATAENTRYX: SET_MAPDATA_VAR_BYTE(entry_x, "EntryX"); break; //B
23157 case MAPDATAENTRYY: SET_MAPDATA_VAR_BYTE(entry_y, "EntryY"); break; //B
23158 case MAPDATAFFDATA:
23159 {
23160 int32_t indx = (ri->d[rINDEX] / 10000)-1;
23161 if(indx < 0 || indx > MAXFFCS-1 )
23162 {
23163 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), "FFCData");
23164 }
23165 else if (mapscr *m = GetMapscr(ri->mapsref))
23166 {
23167 m->ffcs[indx].setData(value/10000);
23168 }
23169 else
23170 {
23171 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised", "FFCData");
23172 }
23173 break; //W, MAXFFCS OF THESE
23174 }
23175 case MAPDATAFFCSET: SET_MAPDATA_FFC_INDEX32(cset, "FFCCSet", MAXFFCS-1); break; //B, MAXFFCS
23176 case MAPDATAFFDELAY: SET_MAPDATA_FFC_INDEX32(delay, "FFCDelay", MAXFFCS-1); break; //W, MAXFFCS
23177 case MAPDATAFFX: SET_MAPDATA_FFCPOS_INDEX32(x, "FFCX", MAXFFCS-1); break; //INT32, MAXFFCS OF THESE
23178 case MAPDATAFFY: SET_MAPDATA_FFCPOS_INDEX32(y, "FFCY", MAXFFCS-1); break; //..
23179 case MAPDATAFFXDELTA: SET_MAPDATA_FFCPOS_INDEX32(vx, "FFCVx", MAXFFCS-1); break; //..
23180 case MAPDATAFFYDELTA: SET_MAPDATA_FFCPOS_INDEX32(vy, "FFCVy", MAXFFCS-1); break; //..
23181 case MAPDATAFFXDELTA2: SET_MAPDATA_FFCPOS_INDEX32(ax, "FFCAx", MAXFFCS-1); break; //..
23182 case MAPDATAFFYDELTA2: SET_MAPDATA_FFCPOS_INDEX32(ay, "FFCAy", MAXFFCS-1); break; //..
23183
23184 case MAPDATAFFFLAGS:
23185 {
23186 int32_t indx = (ri->d[rINDEX] / 10000)-1;
23187 if(indx < 0 || indx > MAXFFCS-1)
23188 {
23189 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), "FFCFlags");
23190 }
23191 else if (mapscr *m = GetMapscr(ri->mapsref))
23192 {
23193 m->ffcs[indx].flags = value/10000;
23194 m->ffcs[indx].updateSolid();
23195 }
23196 else
23197 {
23198 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCFlags");
23199 }
23200 break;
23201 }
23202
23203 //Number of ffcs that are in use (have valid data
23204 case MAPDATANUMFF:
23205 {
23206 break;
23207 }
23208
23209 case MAPDATASIDEWARPID:
23210 {
23211
23212 int32_t indx = ri->d[rINDEX] / 10000; //dir
23213 if (mapscr *m = GetMapscr(ri->mapsref))
23214 {
23215 int32_t new_warp_return = vbound((value / 10000),-1,3); //none, A, B, C, D
23216 if(new_warp_return == -1)
23217 {
23218 m->flags2 &= ~(1<<indx); //Unset the "Enabled" flag for this dir
23219 m->sidewarpindex &= ~(3<<(2*indx)); //Clear the dir as well.
23220 }
23221 else
23222 {
23223 m->flags2 |= 1<<indx; //Set the "Enabled" flag for this dir
23224 m->sidewarpindex &= ~(3<<(2*indx)); //Clear the dir bits
23225 m->sidewarpindex |= (new_warp_return<<(2*indx)); //Set the new dir
23226 }
23227 }
23228 else
23229 {
23230 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","SideWarpID");
23231 }
23232 break;
23233 }
23234
23235 case MAPDATATWARPRETSQR:
23236 {
23237 int32_t indx = ri->d[rINDEX] / 10000;
23238 if ( ((unsigned)indx) > 3)
23239 {
23240 Z_scripterrlog("Invalid Array Index passed to mapdata->TileWarpReturnSquare[]: %d\n", indx);
23241 }
23242 else if (mapscr *m = GetMapscr(ri->mapsref))
23243 {
23244 int32_t wrindex = vbound(value/10000, 0, 3);
23245 m->warpreturnc = (m->warpreturnc&~(3<<(indx*2))) | (wrindex<<(indx*2));
23246 }
23247 else
23248 {
23249 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str");
23250 }
23251 break;
23252 }
23253
23254 //
23255 case MAPDATASWARPRETSQR:
23256 {
23257
23258 int32_t indx = ri->d[rINDEX] / 10000;
23259 if ( ((unsigned)indx) > 3)
23260 {
23261 Z_scripterrlog("Invalid Array Index passed to MAPDATA->SideWarpReturnSquare[]: %d\n", indx);
23262 }
23263 else if (mapscr *m = GetMapscr(ri->mapsref))
23264 {
23265 int32_t wrindex = vbound(value/10000, 0, 3);
23266 m->warpreturnc = (m->warpreturnc&~(3<<(8+(indx*2)))) | (wrindex<<(8+(indx*2)));
23267 }
23268 else
23269 {
23270 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str");
23271 }
23272 break;
23273 }
23274
23275 case MAPDATAFFWIDTH:
23276 {
23277 int32_t indx = (ri->d[rINDEX] / 10000)-1;
23278 if ( indx < 0 || indx > MAXFFCS-1 )
23279 {
23280 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCTileWidth[]: %d\n", indx+1);
23281 }
23282 else if ( (value/10000) < 0 || (value/10000) > 4 )
23283 {
23284 Z_scripterrlog("Invalid WIDTH value passed to MapData->FFCTileWidth[]: %d\n", value/10000);
23285 }
23286 else if (mapscr *m = GetMapscr(ri->mapsref))
23287 {
23288 m->ffTileWidth(indx, (value/10000));
23289 }
23290 else
23291 {
23292 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCTileWidth[]");
23293 }
23294 break;
23295 }
23296
23297 case MAPDATAFFHEIGHT:
23298 {
23299 int32_t indx = (ri->d[rINDEX] / 10000)-1;
23300 if ( indx < 0 || indx > MAXFFCS-1 )
23301 {
23302 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCTileHeight[]: %d\n", indx+1);
23303 }
23304 else if ( (value/10000) < 0 || (value/10000) > 4 )
23305 {
23306 Z_scripterrlog("Invalid WIDTH value passed to MapData->FFCTileHeight[]: %d\n", value/10000);
23307 }
23308 else if (mapscr *m = GetMapscr(ri->mapsref))
23309 {
23310 m->ffTileHeight(indx, (value/10000));
23311 }
23312 else
23313 {
23314 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCTileHeight[]");
23315 }
23316 break;
23317
23318 }
23319
23320 case MAPDATAFFEFFECTWIDTH:
23321 {
23322 int32_t indx = (ri->d[rINDEX] / 10000)-1;
23323 if ( indx < 0 || indx > MAXFFCS-1 )
23324 {
23325 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCEffectWidth[]: %d\n", indx+1);
23326 }
23327 else if ( (value/10000) < 0 )
23328 {
23329 Z_scripterrlog("Invalid WIDTH value passed to MapData->FFCEffectWidth[]: %d\n", value/10000);
23330 }
23331 else if (mapscr *m = GetMapscr(ri->mapsref))
23332 {
23333 m->ffEffectWidth(indx, (value/10000));
23334 }
23335 else
23336 {
23337 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCEffectWidth[]");
23338 }
23339 break;
23340 }
23341
23342 case MAPDATAFFEFFECTHEIGHT:
23343 {
23344 int32_t indx = (ri->d[rINDEX] / 10000)-1;
23345 if ( indx < 0 || indx > MAXFFCS-1 )
23346 {
23347 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCEffectHeight[]: %d\n", indx+1);
23348 }
23349 else if ( (value/10000) < 0 )
23350 {
23351 Z_scripterrlog("Invalid HEIGHT value passed to MapData->FFCEffectHeight[]: %d\n", value/10000);
23352 }
23353 else if (mapscr *m = GetMapscr(ri->mapsref))
23354 {
23355 m->ffEffectHeight(indx, (value/10000));
23356 }
23357 else
23358 {
23359 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCEffectHeight[]");
23360 }
23361 break;
23362 }
23363
23364 case MAPDATAFFLINK: SET_MAPDATA_FFC_INDEX_VBOUND(link, "FFCLink", MAXFFCS-1, 0, MAXFFCS); break; //B, MAXFFCS OF THESE
23365 case MAPDATAFFSCRIPT: SET_MAPDATA_FFC_INDEX_VBOUND(script, "FFCScript", MAXFFCS-1, 0, 255); break; //W, 32 OF THESE
23366
23367 case MAPDATAINTID: //Same form as SetScreenD()
23368 //SetFFCInitD(ffindex, d, value)
23369 {
23370 if (mapscr *m = GetMapscr(ri->mapsref))
23371 {
23372 //int32_t ffindex = ri->d[rINDEX]/10000;
23373 //int32_t d = ri->d[rINDEX2]/10000;
23374 //int32_t v = (value/10000);
23375 int32_t ffid = (ri->d[rINDEX]/10000) -1;
23376 int32_t indx = ri->d[rINDEX2]/10000;
23377
23378 if ( (unsigned)ffid > MAXFFCS-1 )
23379 {
23380 Z_scripterrlog("Invalid FFC id passed to mapdata->FFCInitD[]: %d",ffid);
23381 }
23382 else if ( (unsigned)indx > 7 )
23383 {
23384 Z_scripterrlog("Invalid InitD[] index passed to mapdata->FFCInitD[]: %d",indx);
23385 }
23386 else
23387 {
23388 m->ffcs[ffid].initd[indx] = value;
23389 }
23390 }
23391 else
23392 {
23393 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","SetFFCInitD()");
23394 }
23395 break;
23396 }
23397
23398
23399 //initd //INT32 , 32 OF THESE, EACH WITH 10 INDICES.
23400
23401
23402 case MAPDATAINITA:
23403 //same form as SetScreenD
23404 {
23405 if (mapscr *m = GetMapscr(ri->mapsref))
23406 {//int32_t ffindex = ri->d[rINDEX]/10000;
23407 //int32_t d = ri->d[rINDEX2]/10000;
23408 //int32_t v = (value/10000);
23409 int32_t ffid = (ri->d[rINDEX]/10000) -1;
23410 int32_t indx = ri->d[rINDEX2]/10000;
23411
23412 if ( (unsigned)ffid > MAXFFCS-1 )
23413 {
23414 Z_scripterrlog("Invalid FFC id passed to mapdata->FFCInitD[]: %d",ffid);
23415 }
23416 else if ( (unsigned)indx > 7 )
23417 {
23418 Z_scripterrlog("Invalid InitD[] index passed to mapdata->FFCInitD[]: %d",indx);
23419 }
23420 else
23421 {
23422 m->ffcs[ffid].inita[indx] = value;
23423 }
23424 }
23425 else
23426 {
23427 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","SetFFCInitA()");
23428 }
23429 break;
23430 }
23431
23432 case MAPDATAFFINITIALISED:
23433 {
23434 int32_t indx = ri->d[rINDEX] / 10000;
23435 if(indx < 0 || indx > MAXFFCS-1)
23436 {
23437 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", "FFCRunning", indx);
23438 }
23439 else if (mapscr *m = GetMapscr(ri->mapsref))
23440 {
23441 get_script_engine_data(ScriptType::FFC, indx).initialized = (value/10000) ? true : false;
23442 }
23443 else
23444 {
23445 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n", "FFCRunning");
23446 }
23447 }
23448 break;
23449
23450 case MAPDATASCRIPTENTRY: SET_MAPDATA_VAR_INT32(script_entry, "ScriptEntry"); break; //W
23451 case MAPDATASCRIPTOCCUPANCY: SET_MAPDATA_VAR_INT32(script_occupancy, "ScriptOccupancy"); break;//W
23452 case MAPDATASCRIPTEXIT: SET_MAPDATA_VAR_INT32(script_exit, "ExitScript"); break; //W
23453 case MAPDATAOCEANSFX:
23454 {
23455 if (mapscr *m = GetMapscr(ri->mapsref))
23456 {
23457 int32_t v = vbound(value/10000, 0, 255);
23458 if(m == tmpscr && m->oceansfx != v)
23459 {
23460 stop_sfx(m->oceansfx);
23461 m->oceansfx = v;
23462 cont_sfx(m->oceansfx);
23463 }
23464 else m->oceansfx = v;
23465 }
23466 else
23467 {
23468 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","OceanSFX");
23469 }
23470 break;
23471 }
23472 case MAPDATABOSSSFX: SET_MAPDATA_VAR_BYTE(bosssfx, "BossSFX"); break; //B
23473 case MAPDATASECRETSFX: SET_MAPDATA_VAR_BYTE(secretsfx, "SecretSFX"); break; //B
23474 case MAPDATAHOLDUPSFX: SET_MAPDATA_VAR_BYTE(holdupsfx, "ItemSFX"); break; //B
23475 case MAPDATASCREENMIDI:
23476 {
23477 if (mapscr *m = GetMapscr(ri->mapsref))
23478 {
23479 m->screen_midi = vbound((value / 10000)-(MIDIOFFSET_MAPSCR-MIDIOFFSET_ZSCRIPT),-1,32767);
23480 }
23481 else
23482 {
23483 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","MIDI");
23484 }
23485 break;
23486 }
23487 case MAPDATALENSLAYER: SET_MAPDATA_VAR_BYTE(lens_layer, "LensLayer"); break; //B, OLD QUESTS ONLY?
23488
23489
23490 case MAPDATAFLAGS:
23491 {
23492 int32_t flagid = (ri->d[rINDEX])/10000;
23493 //bool valtrue = ( value ? 10000 : 0);
23494 if(mapscr *m = GetMapscr(ri->mapsref))
23495 {
23496 switch(flagid)
23497 {
23498 case 0: m->flags = (value / 10000); break;
23499 case 1: m->flags2 = (value / 10000); break;
23500 case 2: m->flags3 = (value / 10000); break;
23501 case 3: m->flags4 = (value / 10000); break;
23502 case 4: m->flags5 = (value / 10000); break;
23503 case 5: m->flags6 = (value / 10000); break;
23504 case 6: m->flags7 = (value / 10000); break;
23505 case 7: m->flags8 = (value / 10000); break;
23506 case 8: m->flags9 = (value / 10000); break;
23507 case 9: m->flags10 = (value / 10000); break;
23508 default:
23509 {
23510 Z_scripterrlog("Invalid index passed to mapdata->flags[]: %d\n", flagid);
23511 break;
23512 }
23513 }
23514 }
23515 else
23516 {
23517 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Flags[]");
23518 }
23519 break;
23520 //SET_MAPDATA_BYTE_INDEX //B, 11 OF THESE, flags, flags2-flags10
23521 }
23522
23523 case MAPDATAMISCD:
23524 {
23525 if(mapscr* m = GetMapscr(ri->mapsref))
23526 {
23527 int32_t indx = (ri->d[rINDEX])/10000;
23528 int32_t mi = get_mi(ri->mapsref);
23529 if(mi<0) break;
23530 if( ((unsigned)indx) > 7 )
23531 {
23532 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", indx);
23533 break;
23534 }
23535 else
23536 {
23537 game->screen_d[mi][indx] = value/10000;
23538 break;
23539 }
23540 }
23541 else
23542 {
23543 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","D[]");
23544 }
23545 break;
23546 }
23547
23548
23549 case MAPDATACOMBODD:
23550 {
23551 80782 int32_t pos = (ri->d[rINDEX])/10000;
23552 80782 int32_t val = (value/10000);
23553
23554
1/2
✓ Branch 0 taken 80782 times.
✗ Branch 1 not taken.
80782 if(mapscr *m = GetMapscr(ri->mapsref))
23555 {
23556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80782 times.
80782 if ( ((unsigned) pos) > 175 )
23557 {
23558 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboD[]\n", pos);
23559 }
23560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80782 times.
80782 else if ( ((unsigned) val) >= MAXCOMBOS )
23561 {
23562 Z_scripterrlog("Invalid combo ID %d used to write to mapdata->ComboD[]\n", val);
23563 }
23564 else
23565 {
23566 80782 screen_combo_modify_preroutine(m,pos);
23567 80782 m->data[pos]=val;
23568 80782 screen_combo_modify_postroutine(m,pos);
23569 }
23570 80782 }
23571 else
23572 {
23573 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboD[]");
23574 }
23575 }
23576 80782 break;
23577
23578 case MAPDATACOMBOCD:
23579 {
23580 2497 int32_t pos = (ri->d[rINDEX])/10000;
23581 2497 int32_t val = (value/10000); //cset
23582
1/2
✓ Branch 0 taken 2497 times.
✗ Branch 1 not taken.
2497 if(mapscr *m = GetMapscr(ri->mapsref))
23583 {
23584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2497 times.
2497 if ( ((unsigned) pos) > 175 )
23585 {
23586 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboC[]\n", pos);
23587 }
23588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2497 times.
2497 else if ( ((unsigned) val) >= 15 )
23589 {
23590 Z_scripterrlog("Invalid CSet ID %d used to write to mapdata->ComboC[]\n", val);
23591 }
23592 else
23593 {
23594 2497 screen_combo_modify_preroutine(m,pos);
23595 2497 m->cset[pos]=(val)&15;
23596 2497 screen_combo_modify_postroutine(m,pos);
23597 }
23598 2497 }
23599 else
23600 {
23601 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboC[]");
23602 }
23603 }
23604 2497 break;
23605
23606 case MAPDATACOMBOFD:
23607 {
23608 56174 int32_t pos = (ri->d[rINDEX])/10000;
23609 56174 int32_t val = (value/10000); //flag
23610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56174 times.
56174 if(mapscr *m = GetMapscr(ri->mapsref))
23611 {
23612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56174 times.
56174 if ( ((unsigned) pos) > 175 )
23613 {
23614 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboF[]\n", pos);
23615 }
23616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56174 times.
56174 else if ( ((unsigned) val) >= 256 )
23617 {
23618 Z_scripterrlog("Invalid Flag ID %d used to write to mapdata->ComboF[]\n", val);
23619 }
23620
23621 else
23622 56174 m->sflag[pos]=(val);
23623 56174 }
23624 else
23625 {
23626 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboF[]");
23627 }
23628 }
23629 56174 break;
23630
23631 case MAPDATACOMBOTD:
23632 {
23633 int32_t pos = (ri->d[rINDEX])/10000;
23634 int32_t val = (value/10000); //type
23635 if(mapscr *m = GetMapscr(ri->mapsref))
23636 {
23637 if ( ((unsigned) pos) > 175 )
23638 {
23639 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboT[]\n", pos);
23640 }
23641 else if ( ((unsigned) val) >= cMAX )
23642 {
23643 Z_scripterrlog("Invalid Type ID %d used to write to mapdata->ComboT[]\n", val);
23644 }
23645 else
23646 {
23647 auto cid = m->data[pos];
23648 screen_combo_modify_pre(cid);
23649 combobuf[cid].type=val;
23650 screen_combo_modify_post(cid);
23651 }
23652 }
23653 else
23654 {
23655 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboT[]");
23656 }
23657 }
23658 break;
23659
23660 case MAPDATACOMBOID:
23661 {
23662 int32_t pos = (ri->d[rINDEX])/10000;
23663 int32_t val = (value/10000); //iflag
23664 if(mapscr *m = GetMapscr(ri->mapsref))
23665 {
23666 if ( ((unsigned) pos) > 175 )
23667 {
23668 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboI[]\n", pos);
23669 }
23670 else if ( ((unsigned) val) >= 256 )
23671 {
23672 Z_scripterrlog("Invalid Flag ID %d used to write to mapdata->ComboI[]\n", val);
23673 }
23674
23675 else
23676 combobuf[m->data[pos]].flag=value/10000;
23677 }
23678 else
23679 {
23680 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboI[]");
23681 }
23682 }
23683 break;
23684
23685 case MAPDATACOMBOSD:
23686 {
23687 int32_t pos = (ri->d[rINDEX])/10000;
23688 int32_t val = (value/10000); //solidity
23689 if(mapscr *m = GetMapscr(ri->mapsref))
23690 {
23691 if ( ((unsigned) pos) > 175 )
23692 {
23693 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboS[]\n", pos);
23694 }
23695 else if ( ((unsigned) val) >= 16 )
23696 {
23697 Z_scripterrlog("Invalid Solidity %d used to write to mapdata->ComboS[]\n", val);
23698 }
23699
23700 else
23701 {
23702 combobuf[m->data[pos]].walk &= ~0x0F;
23703 combobuf[m->data[pos]].walk |= (val)&0x0F;
23704 }
23705 }
23706 else
23707 {
23708 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboS[]");
23709 }
23710 }
23711 break;
23712
23713 case MAPDATACOMBOED:
23714 {
23715 int32_t pos = (ri->d[rINDEX])/10000;
23716 int32_t val = (value/10000); //solidity
23717 if(mapscr *m = GetMapscr(ri->mapsref))
23718 {
23719 if ( ((unsigned) pos) > 175 )
23720 {
23721 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboE[]\n", pos);
23722 }
23723 else if ( ((unsigned) val) >= 16 )
23724 {
23725 Z_scripterrlog("Invalid Solidity %d used to write to mapdata->ComboE[]\n", val);
23726 }
23727
23728 else
23729 {
23730 combobuf[m->data[pos]].walk &= ~0xF0;
23731 combobuf[m->data[pos]].walk |= ((val)&0x0F)<<4;
23732 }
23733 }
23734 else
23735 {
23736 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboE[]");
23737 }
23738 }
23739 break;
23740
23741 case MAPDATASCREENSTATED:
23742 {
23743 if(mapscr* m = GetMapscr(ri->mapsref))
23744 {
23745 int32_t mi = get_mi(ri->mapsref);
23746 if(mi<0) break;
23747 (value)?setmapflag(mi, 1<<((ri->d[rINDEX])/10000)) : unsetmapflag(mi, 1 << ((ri->d[rINDEX]) / 10000));
23748 }
23749 else
23750 {
23751 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","State[]");
23752 }
23753 }
23754 break;
23755 case MAPDATAEXSTATED:
23756 {
23757 if(mapscr* m = GetMapscr(ri->mapsref))
23758 {
23759 int32_t mi = get_mi(ri->mapsref);
23760 if(mi<0) break;
23761 (value)?setxmapflag(mi, 1<<((ri->d[rINDEX])/10000)) : unsetxmapflag(mi, 1 << ((ri->d[rINDEX]) / 10000));
23762 }
23763 else
23764 {
23765 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","State[]");
23766 }
23767 break;
23768 }
23769 case MAPDATALENSSHOWS:
23770 {
23771 int ind = ri->d[rINDEX]/10000;
23772 if(ind < 0 || ind > 6)
23773 Z_scripterrlog("Bad index mapdata->LensShows[%d]\n",ind);
23774 else if(mapscr *m = GetMapscr(ri->mapsref))
23775 {
23776 SETFLAG(m->lens_show, 1<<ind, value);
23777 if(value) m->lens_hide &= ~(1<<ind);
23778 }
23779 else Z_scripterrlog("mapdata->LensShows[] pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
23780 break;
23781 }
23782 case MAPDATALENSHIDES:
23783 {
23784 int ind = ri->d[rINDEX]/10000;
23785 if(ind < 0 || ind > 6)
23786 Z_scripterrlog("Bad index mapdata->LensHides[%d]\n",ind);
23787 else if(mapscr *m = GetMapscr(ri->mapsref))
23788 {
23789 SETFLAG(m->lens_hide, 1<<ind, value);
23790 if(value) m->lens_show &= ~(1<<ind);
23791 }
23792 else Z_scripterrlog("mapdata->LensHides[] pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
23793 break;
23794 }
23795 case MAPDATASCRDATASIZE:
23796 {
23797 if(mapscr *m = GetMapscr(ri->mapsref))
23798 {
23799 auto mi = get_total_mi(ri->mapsref);
23800 if(mi < 0) break;
23801 game->scriptDataResize(mi, value/10000);
23802 }
23803 else Z_scripterrlog("mapdata->DataSize pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
23804 break;
23805 }
23806 case MAPDATASCRDATA:
23807 {
23808 if(mapscr *m = GetMapscr(ri->mapsref))
23809 {
23810 auto mi = get_total_mi(ri->mapsref);
23811 if(mi < 0) break;
23812 size_t indx = ri->d[rINDEX]/10000;
23813 if(indx >= game->scriptDataSize(mi))
23814 Z_scripterrlog("Invalid index passed to mapdata->Data[]: %d\n", indx);
23815 else game->screen_data[mi][indx] = value;
23816 }
23817 else Z_scripterrlog("mapdata->Data[] pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
23818 break;
23819 }
23820
23821 ///----------------------------------------------------------------------------------------------------//
23822 //shopdata sd-> Variables
23823
23824 case SHOPDATAITEM:
23825 {
23826
23827 int32_t ref = ri->shopsref;
23828 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
23829 int32_t indx = ri->d[rINDEX] / 10000;
23830 if ( indx < 0 || indx > 2 )
23831 {
23832 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "Item");
23833 break;
23834 }
23835 else
23836 {
23837 if ( isInfo )
23838 {
23839 Z_scripterrlog("Attempted to write an 'item' to an infoshop, using shop ID: %d\n", ri->shopsref);
23840 break;
23841 }
23842 else
23843 {
23844 QMisc.shop[ref].item[indx] = (byte)(vbound((value/10000), 0, 255));
23845 break;
23846 }
23847 }
23848 }
23849 break;
23850 //SET_SHOPDATA_VAR_INDEX(item, "Item", 2); break;
23851 case SHOPDATAHASITEM:
23852 {
23853
23854 int32_t ref = ri->shopsref;
23855 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
23856 int32_t indx = ri->d[rINDEX] / 10000;
23857 if ( indx < 0 || indx > 2 )
23858 {
23859 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "HasItem");
23860 break;
23861 }
23862 else
23863 {
23864 if ( isInfo )
23865 {
23866 Z_scripterrlog("Attempted to write 'hasitem' to an infoshop, using shop ID: %d\n", ri->shopsref);
23867 break;
23868 }
23869 else
23870 {
23871 QMisc.shop[ref].hasitem[indx] = (byte)(vbound((value/10000), 0, 255)); break;
23872 }
23873 }
23874 }
23875 break;
23876 //SET_SHOPDATA_VAR_INDEX(hasitem, "HasItem", 2); break;
23877 case SHOPDATAPRICE:
23878 {
23879
23880 int32_t ref = ri->shopsref;
23881 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
23882 int32_t indx = ri->d[rINDEX] / 10000;
23883 if ( indx < 0 || indx > 2 )
23884 {
23885 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "Price");
23886 break;
23887 }
23888 else
23889 {
23890 if ( isInfo )
23891 {
23892 QMisc.info[ref - NUMSHOPS].price[indx] = (word)(vbound((value/10000), 0, 65535));
23893 break;
23894 }
23895 else
23896 {
23897 QMisc.shop[ref].price[indx] = (word)(vbound((value/10000), 0, 65535));
23898 break;
23899 }
23900 }
23901 }
23902 //SET_SHOPDATA_VAR_INDEX(price, "Price", 2); break;
23903 //Pay for info
23904 case SHOPDATASTRING:
23905 {
23906 {
23907 int32_t ref = ri->shopsref;
23908 if ( ref < NUMSHOPS || ref > NUMINFOSHOPS )
23909 {
23910 Z_scripterrlog("Invalid Info Shop ID passed to shopdata->String[]: %d\n", ref);
23911 break;
23912 }
23913 else
23914 {
23915 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
23916 int32_t indx = ri->d[rINDEX] / 10000;
23917 if ( indx < 0 || indx > 2 )
23918 {
23919 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "HasItem");
23920 break;
23921 }
23922 else
23923 {
23924 if ( isInfo )
23925 {
23926 QMisc.info[ref - NUMSHOPS].str[indx] = (word)(vbound((value/10000), 0, 32767));
23927 break;
23928 }
23929 else
23930 {
23931 QMisc.shop[ref].str[indx] = (word)(vbound((value/10000), 0, 32767));
23932 break;
23933 }
23934 }
23935
23936
23937 }
23938
23939 //GET_SHOPDATA_VAR_INDEX(str, String, 2); break;
23940 } break;
23941 }
23942
23943 ///----------------------------------------------------------------------------------------------------//
23944 //dmapdata dmd-> Variables
23945 case DMAPDATAMAP: //byte
23946 {
23947 DMaps[ri->dmapsref].map = ((byte)(value / 10000)) - 1; break;
23948 }
23949 case DMAPDATALEVEL: //word
23950 {
23951 DMaps[ri->dmapsref].level = ((word)(value / 10000)); break;
23952 }
23953 case DMAPDATAOFFSET: //char
23954 {
23955 DMaps[ri->dmapsref].xoff = ((char)(value / 10000)); break;
23956 }
23957 case DMAPDATACOMPASS: //byte
23958 {
23959 DMaps[ri->dmapsref].compass = ((byte)(value / 10000)); break;
23960 }
23961 case DMAPDATAPALETTE: //word
23962 {
23963 DMaps[ri->dmapsref].color= ((word)(value / 10000));
23964 if(ri->dmapsref == currdmap)
23965 {
23966 loadlvlpal(DMaps[ri->dmapsref].color);
23967 currcset = DMaps[ri->dmapsref].color;
23968 }
23969 break;
23970 }
23971 case DMAPDATAMIDI: //byte
23972 {
23973 DMaps[ri->dmapsref].midi = ((byte)((value / 10000)+MIDIOFFSET_DMAP)); break;
23974 }
23975 case DMAPDATACONTINUE: //byte
23976 {
23977 DMaps[ri->dmapsref].cont = ((byte)(value / 10000)); break;
23978 }
23979 case DMAPDATATYPE: //byte
23980 {
23981 DMaps[ri->dmapsref].type = (((byte)(value / 10000))&dmfTYPE) | (DMaps[ri->dmapsref].type&~dmfTYPE); break;
23982 }
23983 case DMAPSCRIPT: //byte
23984 {
23985 FFScript::deallocateAllScriptOwned(ScriptType::DMap, ri->dmapsref);
23986 DMaps[ri->dmapsref].script = vbound((value / 10000),0,NUMSCRIPTSDMAP-1); break;
23987 }
23988 case DMAPDATASIDEVIEW: //byte, treat as bool
23989 {
23990 DMaps[ri->dmapsref].sideview = ((value) ? 1 : 0); break;
23991 }
23992 case DMAPDATAGRID: //byte[8] --array
23993 {
23994 int32_t indx = ri->d[rINDEX] / 10000;
23995 if ( indx < 0 || indx > 7 )
23996 {
23997 Z_scripterrlog("Invalid index supplied to dmapdata->Grid[]: %d\n", indx); break;
23998 }
23999 else
24000 {
24001 DMaps[ri->dmapsref].grid[indx] = ((byte)(value / 10000)); break;
24002 }
24003 }
24004 case DMAPINITD:
24005 {
24006 int32_t indx = ri->d[rINDEX] / 10000;
24007 if ( indx < 0 || indx > 7 )
24008 {
24009 Z_scripterrlog("Invalid index supplied to dmapdata->InitD[]: %d\n", indx); break;
24010 }
24011 else
24012 {
24013 DMaps[ri->dmapsref].initD[indx] = value; break;
24014 }
24015 }
24016 case DMAPDATAMINIMAPTILE: //word - two of these, so let's do MinimapTile[2]
24017 {
24018 int32_t indx = ri->d[rINDEX] / 10000;
24019 switch(indx)
24020 {
24021 case 0: { DMaps[ri->dmapsref].minimap_1_tile = ((word)(value / 10000)); break; }
24022 case 1: { DMaps[ri->dmapsref].minimap_2_tile = ((word)(value / 10000)); break; }
24023 default:
24024 {
24025 Z_scripterrlog("Invalid index supplied to dmapdata->MiniMapTile[]: %d\n", indx);
24026 break;
24027 }
24028 }
24029 break;
24030 }
24031 case DMAPDATAMINIMAPCSET: //byte - two of these, so let's do MinimapCSet[2]
24032 {
24033 int32_t indx = ri->d[rINDEX] / 10000;
24034 switch(indx)
24035 {
24036 case 0: { DMaps[ri->dmapsref].minimap_1_cset= ((byte)(value / 10000)); break; }
24037 case 1: { DMaps[ri->dmapsref].minimap_2_cset= ((byte)(value / 10000)); break; }
24038 default:
24039 {
24040 Z_scripterrlog("Invalid index supplied to dmapdata->MiniMapCSet[]: %d\n", indx);
24041 break;
24042 }
24043 }
24044 break;
24045 }
24046 case DMAPDATALARGEMAPTILE: //word -- two of these, so let's to LargemapTile[2]
24047 {
24048 int32_t indx = ri->d[rINDEX] / 10000;
24049 switch(indx)
24050 {
24051 case 0: { DMaps[ri->dmapsref].largemap_1_tile = ((word)(value / 10000)); break; }
24052 case 1: { DMaps[ri->dmapsref].largemap_2_tile = ((word)(value / 10000)); break; }
24053 default:
24054 {
24055 Z_scripterrlog("Invalid index supplied to dmapdata->LargeMapTile[]: %d\n", indx);
24056 break;
24057 }
24058 }
24059 break;
24060 }
24061 case DMAPDATALARGEMAPCSET: //word -- two of these, so let's to LargemaCSet[2]
24062 {
24063 int32_t indx = ri->d[rINDEX] / 10000;
24064 switch(indx)
24065 {
24066 case 0: { DMaps[ri->dmapsref].largemap_1_cset= ((byte)(value / 10000)); break; }
24067 case 1: { DMaps[ri->dmapsref].largemap_2_cset= ((byte)(value / 10000)); break; }
24068 default:
24069 {
24070 Z_scripterrlog("Invalid index supplied to dmapdata->LargeMapCSet[]: %d\n", indx);
24071 break;
24072 }
24073 }
24074 break;
24075 }
24076 case DMAPDATAMUISCTRACK: //byte
24077 {
24078 DMaps[ri->dmapsref].tmusictrack= ((byte)(value / 10000)); break;
24079 }
24080 case DMAPDATASUBSCRA:
24081 {
24082 bool changed = DMaps[ri->dmapsref].active_subscreen != ((byte)(value / 10000));
24083 DMaps[ri->dmapsref].active_subscreen= ((byte)(value / 10000));
24084 if(changed&&ri->dmapsref==currdmap)
24085 update_subscreens();
24086 break;
24087 }
24088 case DMAPDATASUBSCRP:
24089 {
24090 bool changed = DMaps[ri->dmapsref].passive_subscreen != ((byte)(value / 10000));
24091 DMaps[ri->dmapsref].passive_subscreen= ((byte)(value / 10000));
24092 if(changed&&ri->dmapsref==currdmap)
24093 update_subscreens();
24094 break;
24095 }
24096 case DMAPDATASUBSCRO:
24097 {
24098 bool changed = DMaps[ri->dmapsref].overlay_subscreen != ((byte)(value / 10000));
24099 DMaps[ri->dmapsref].overlay_subscreen = ((byte)(value / 10000));
24100 if(changed&&ri->dmapsref==currdmap)
24101 update_subscreens();
24102 break;
24103 }
24104 case DMAPDATADISABLEDITEMS: //byte[MAXITEMS]
24105 {
24106 int32_t indx = ri->d[rINDEX] / 10000;
24107 if ( indx < 0 || indx > (MAXITEMS-1) )
24108 {
24109 Z_scripterrlog("Invalid index supplied to dmapdata->Grid[]: %d\n", indx); break;
24110 }
24111 else
24112 {
24113 DMaps[ri->dmapsref].disableditems[indx] = ((byte)(value / 10000)); break;
24114 }
24115 }
24116
24117 case DMAPDATAFLAGARR: //int32_t
24118 {
24119 int32_t indx = ri->d[rINDEX] / 10000;
24120 if ( ((unsigned)indx) > 31 )
24121 {
24122 Z_scripterrlog("Invalid index supplied to dmapdata->Flags[]: %d\n", indx);
24123 break;
24124 }
24125 if ( value ) DMaps[ri->dmapsref].flags |= (1<<indx);
24126 else DMaps[ri->dmapsref].flags &= ~(1<<indx);
24127 break;
24128 }
24129 case DMAPDATAFLAGS: //int32_t
24130 {
24131 DMaps[ri->dmapsref].flags = (value / 10000); break;
24132 }
24133 case DMAPDATAMIRRDMAP:
24134 {
24135 DMaps[ri->dmapsref].mirrorDMap = vbound(value / 10000, -1, MAXDMAPS); break;
24136 }
24137 case DMAPDATALOOPSTART:
24138 {
24139 DMaps[ri->dmapsref].tmusic_loop_start = value;
24140 if (ri->dmapsref == currdmap)
24141 {
24142 if (FFCore.doing_dmap_enh_music(currdmap))
24143 {
24144 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
24145 }
24146 }
24147 break;
24148 }
24149 case DMAPDATALOOPEND:
24150 {
24151 DMaps[ri->dmapsref].tmusic_loop_end = value;
24152 if (ri->dmapsref == currdmap)
24153 {
24154 if (FFCore.doing_dmap_enh_music(currdmap))
24155 {
24156 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
24157 }
24158 }
24159 break;
24160 }
24161 case DMAPDATAXFADEIN:
24162 {
24163 DMaps[ri->dmapsref].tmusic_xfade_in = (value / 10000);
24164 break;
24165 }
24166 case DMAPDATAXFADEOUT:
24167 {
24168 DMaps[ri->dmapsref].tmusic_xfade_out = (value / 10000);
24169 if (DMaps[currdmap].tmusic[0]!=0 && strcmp(DMaps[ri->dmapsref].tmusic, zcmusic->filename) == 0)
24170 {
24171 zcmusic->fadeoutframes = (value / 10000);
24172 }
24173 break;
24174 }
24175 case DMAPDATAINTROSTRINGID:
24176 {
24177 DMaps[ri->dmapsref].intro_string_id = (value / 10000);
24178 break;
24179 }
24180 case MUSICUPDATECOND:
24181 {
24182 FFCore.music_update_cond = vbound(value / 10000, 0, 255);
24183 break;
24184 }
24185 case MUSICUPDATEFLAGS:
24186 {
24187 int32_t indx = ri->d[rINDEX] / 10000;
24188 if (indx < 0 || indx > 1)
24189 {
24190 Z_scripterrlog("Invalid Index passed to Audio->MusicRefreshFlags[]: %d\n", indx);
24191 break;
24192 }
24193 SETFLAG(FFCore.music_update_flags, 1 << indx, value);
24194 break;
24195 }
24196 case DMAPDATAASUBSCRIPT: //byte
24197 {
24198 FFScript::deallocateAllScriptOwned(ScriptType::ScriptedActiveSubscreen, ri->dmapsref);
24199 DMaps[ri->dmapsref].active_sub_script = vbound((value / 10000),0,NUMSCRIPTSDMAP-1); break;
24200 }
24201 case DMAPDATAMAPSCRIPT: //byte
24202 {
24203 3225 FFScript::deallocateAllScriptOwned(ScriptType::OnMap, ri->dmapsref);
24204 3225 DMaps[ri->dmapsref].onmap_script = vbound((value / 10000),0,NUMSCRIPTSDMAP-1); break;
24205 }
24206 case DMAPDATAPSUBSCRIPT: //byte
24207 {
24208 FFScript::deallocateAllScriptOwned(ScriptType::ScriptedPassiveSubscreen, ri->dmapsref);
24209 word val = vbound((value / 10000),0,NUMSCRIPTSDMAP-1);
24210 if (FFCore.doscript(ScriptType::ScriptedPassiveSubscreen) && ri->dmapsref == currdmap && val == DMaps[ri->dmapsref].passive_sub_script)
24211 break;
24212 DMaps[ri->dmapsref].passive_sub_script = val;
24213 if(ri->dmapsref == currdmap)
24214 {
24215 FFCore.doscript(ScriptType::ScriptedPassiveSubscreen) = val != 0;
24216 };
24217 break;
24218 }
24219 case DMAPDATASUBINITD:
24220 {
24221 int32_t indx = ri->d[rINDEX] / 10000;
24222 if ( indx < 0 || indx > 7 )
24223 {
24224 Z_scripterrlog("Invalid index supplied to dmapdata->SubInitD[]: %d\n", indx); break;
24225 }
24226 else
24227 {
24228 DMaps[ri->dmapsref].sub_initD[indx] = value; break;
24229 }
24230 }
24231
24232 case DMAPDATAMAPINITD:
24233 {
24234 int32_t indx = ri->d[rINDEX] / 10000;
24235 if ( indx < 0 || indx > 7 )
24236 {
24237 Z_scripterrlog("Invalid index supplied to dmapdata->MapInitD[]: %d\n", indx); break;
24238 }
24239 else
24240 {
24241 DMaps[ri->dmapsref].onmap_initD[indx] = value; break;
24242 }
24243 }
24244
24245 case DMAPDATACHARTED:
24246 {
24247 int32_t scr = ri->d[rINDEX] / 10000;
24248 if(ri->dmapsref >= MAXDMAPS)
24249 {
24250 Z_scripterrlog("Invalid DMap reference used for dmapdata->Charted[]: %d\n", ri->dmapsref);
24251 }
24252 // else if((DMaps[get_currdmap()].type&dmfTYPE) == dmOVERW)
24253 // {
24254 // Z_scripterrlog("dmapdata->Charted[] cannot presently be used on Overworld-type dmaps\n");
24255 // }
24256 else if(((unsigned)(scr)) > 127)
24257 {
24258 Z_scripterrlog("Invalid index supplied to dmapdata->Charted[]: %d\n", scr);
24259 }
24260 else
24261 {
24262 int32_t col = (scr&15)-(DMaps[ri->dmapsref].type==dmOVERW ? 0 : DMaps[ri->dmapsref].xoff);
24263 if((DMaps[ri->dmapsref].type&dmfTYPE)!=dmOVERW ? (((unsigned)col) > 7) : (((unsigned)col) > 15))
24264 break; //Out-of-bounds; don't attempt write!
24265 int32_t di = (ri->dmapsref << 7) + (scr & 0x7F);
24266 game->bmaps[di] = (value/10000)&0x8F;
24267 }
24268 break;
24269 }
24270 //case DMAPDATAGRAVITY: //unimplemented
24271 //case DMAPDATAJUMPLAYER: //unimplemented
24272
24273 ///----------------------------------------------------------------------------------------------------//
24274 //messagedata msgd-> Variables
24275
24276
24277 case MESSAGEDATANEXT: //W
24278 {
24279 int32_t ID = ri->zmsgref;
24280
24281 if(BC::checkMessage(ID, "messagedata->Next") != SH::_NoError)
24282 break;
24283 else
24284 MsgStrings[ID].nextstring = vbound((value/10000), 0, (msg_count-1));
24285 break;
24286 }
24287
24288 case MESSAGEDATATILE: //W
24289 {
24290 int32_t ID = ri->zmsgref;
24291
24292 if(BC::checkMessage(ID, "messagedata->Tile") != SH::_NoError)
24293 break;
24294 else
24295 MsgStrings[ID].tile = vbound((value/10000), 0, (NEWMAXTILES));
24296 break;
24297 }
24298
24299 case MESSAGEDATACSET: //b
24300 {
24301 int32_t ID = ri->zmsgref;
24302
24303 if(BC::checkMessage(ID, "messagedata->CSet") != SH::_NoError)
24304 break;
24305 else
24306 MsgStrings[ID].cset = ((byte)vbound((value/10000), 0, 15));
24307 break;
24308 }
24309 case MESSAGEDATATRANS: //BOOL
24310 {
24311 int32_t ID = ri->zmsgref;
24312
24313 if(BC::checkMessage(ID, "messagedata->Transparent") != SH::_NoError)
24314 break;
24315 else
24316 (MsgStrings[ID].trans) = ((value)?true:false);
24317 break;
24318 }
24319 case MESSAGEDATAFONT: //B
24320 {
24321 int32_t ID = ri->zmsgref;
24322
24323 if(BC::checkMessage(ID, "messagedata->Font") != SH::_NoError)
24324 break;
24325 else
24326 MsgStrings[ID].font = ((byte)vbound((value/10000), 0, 255));
24327 break;
24328 }
24329 case MESSAGEDATAX: //SHORT
24330 {
24331 int32_t ID = ri->zmsgref;
24332
24333 if(BC::checkMessage(ID, "messagedata->X") != SH::_NoError)
24334 break;
24335 else
24336 MsgStrings[ID].x = ((int16_t)vbound((value/10000), SHRT_MIN, SHRT_MAX));
24337 break;
24338 }
24339 case MESSAGEDATAY: //SHORT
24340 {
24341 int32_t ID = ri->zmsgref;
24342
24343 if(BC::checkMessage(ID, "messagedata->Y") != SH::_NoError)
24344 break;
24345 else
24346 MsgStrings[ID].y = ((int16_t)vbound((value/10000), SHRT_MIN, SHRT_MAX));
24347 break;
24348 }
24349 case MESSAGEDATAW: //UNSIGNED SHORT
24350 {
24351 int32_t ID = ri->zmsgref;
24352
24353 if(BC::checkMessage(ID, "messagedata->Width") != SH::_NoError)
24354 break;
24355 else
24356 MsgStrings[ID].w = ((uint16_t)vbound((value/10000), 0, USHRT_MAX));
24357 break;
24358 }
24359 case MESSAGEDATAH: //UNSIGNED SHORT
24360 {
24361 int32_t ID = ri->zmsgref;
24362
24363 if(BC::checkMessage(ID, "messagedata->Height") != SH::_NoError)
24364 break;
24365 else
24366 MsgStrings[ID].h = ((uint16_t)vbound((value/10000), 0, USHRT_MAX));
24367 break;
24368 }
24369 case MESSAGEDATASFX: //BYTE
24370 {
24371 int32_t ID = ri->zmsgref;
24372
24373 if(BC::checkMessage(ID, "messagedata->Sound") != SH::_NoError)
24374 break;
24375 else
24376 MsgStrings[ID].sfx = ((byte)vbound((value/10000), 0, 255));
24377 break;
24378 }
24379 case MESSAGEDATALISTPOS: //WORD
24380 {
24381 int32_t ID = ri->zmsgref;
24382
24383 if(BC::checkMessage(ID, "messagedata->ListPosition") != SH::_NoError)
24384 break;
24385 else
24386 MsgStrings[ID].listpos = vbound((value/10000), 1, (msg_count-1));
24387 break;
24388 }
24389 case MESSAGEDATAVSPACE: //BYTE
24390 {
24391 int32_t ID = ri->zmsgref;
24392
24393 if(BC::checkMessage(ID, "messagedata->VSpace") != SH::_NoError)
24394 break;
24395 else
24396 MsgStrings[ID].vspace = ((byte)vbound((value/10000), 0, 255));
24397 break;
24398 }
24399 case MESSAGEDATAHSPACE: //BYTE
24400 {
24401 int32_t ID = ri->zmsgref;
24402
24403 if(BC::checkMessage(ID, "messagedata->HSpace") != SH::_NoError)
24404 break;
24405 else
24406 MsgStrings[ID].hspace = ((byte)vbound((value/10000), 0, 255));
24407 break;
24408 }
24409 case MESSAGEDATAFLAGS: //BYTE
24410 {
24411 int32_t ID = ri->zmsgref;
24412
24413 if(BC::checkMessage(ID, "messagedata->Flags") != SH::_NoError)
24414 break;
24415 else
24416 MsgStrings[ID].stringflags = ((byte)vbound((value/10000), 0, 255));
24417 break;
24418 }
24419 case MESSAGEDATAMARGINS: //BYTE, 4
24420 {
24421 int32_t indx = ri->d[rINDEX] / 10000;
24422 if ( indx < 0 || indx > 3 )
24423 {
24424 Z_scripterrlog("Invalid index supplied to messagedata->Margins[]: %d\n", indx);
24425 break;
24426 }
24427 int32_t ID = ri->zmsgref;
24428
24429 if(BC::checkMessage(ID, "messagedata->Margins[]") != SH::_NoError)
24430 break;
24431 else
24432 MsgStrings[ID].margins[indx] = ((byte)vbound((value/10000), 0, 255));
24433 break;
24434 }
24435 case MESSAGEDATAPORTTILE: //INT
24436 {
24437 int32_t ID = ri->zmsgref;
24438
24439 if(BC::checkMessage(ID, "messagedata->PortraitTile") != SH::_NoError)
24440 break;
24441 else
24442 MsgStrings[ID].portrait_tile = vbound((value/10000), 0, (NEWMAXTILES));
24443 break;
24444 }
24445 case MESSAGEDATAPORTCSET: //BYTE
24446 {
24447 int32_t ID = ri->zmsgref;
24448
24449 if(BC::checkMessage(ID, "messagedata->PortraitCSet") != SH::_NoError)
24450 break;
24451 else
24452 MsgStrings[ID].portrait_cset = ((byte)vbound((value/10000), 0, 15));
24453 break;
24454 }
24455 case MESSAGEDATAPORTX: //BYTE
24456 {
24457 int32_t ID = ri->zmsgref;
24458
24459 if(BC::checkMessage(ID, "messagedata->PortraitX") != SH::_NoError)
24460 break;
24461 else
24462 MsgStrings[ID].portrait_x = ((byte)vbound((value/10000), 0, 255));
24463 break;
24464 }
24465 case MESSAGEDATAPORTY: //BYTE
24466 {
24467 int32_t ID = ri->zmsgref;
24468
24469 if(BC::checkMessage(ID, "messagedata->PortraitY") != SH::_NoError)
24470 break;
24471 else
24472 MsgStrings[ID].portrait_y = ((byte)vbound((value/10000), 0, 255));
24473 break;
24474 }
24475 case MESSAGEDATAPORTWID: //BYTE
24476 {
24477 int32_t ID = ri->zmsgref;
24478
24479 if(BC::checkMessage(ID, "messagedata->PortraitTileWidth") != SH::_NoError)
24480 break;
24481 else
24482 MsgStrings[ID].portrait_tw = ((byte)vbound((value/10000), 0, 16));
24483 break;
24484 }
24485 case MESSAGEDATAPORTHEI: //BYTE
24486 {
24487 int32_t ID = ri->zmsgref;
24488
24489 if(BC::checkMessage(ID, "messagedata->PortraitTileHeight") != SH::_NoError)
24490 break;
24491 else
24492 MsgStrings[ID].portrait_th = ((byte)vbound((value/10000), 0, 14));
24493 break;
24494 }
24495 case MESSAGEDATAFLAGSARR: //BOOL, 7
24496 {
24497 int32_t indx = ri->d[rINDEX] / 10000;
24498 int32_t ID = ri->zmsgref;
24499
24500 if(BC::checkMessage(ID, "messagedata->Flags[]") != SH::_NoError)
24501 break;
24502 else
24503 {
24504 switch(indx)
24505 {
24506 case 0:
24507 (value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_WRAP : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_WRAP;
24508 break;
24509 case 1:
24510 (value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_CONT : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_CONT;
24511 break;
24512 case 2: //Not implemented
24513 //(value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_CENTER : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_CENTER;
24514 break;
24515 case 3: //Not implemented
24516 //(value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_RIGHT : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_RIGHT;
24517 break;
24518 case 4:
24519 (value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_FULLTILE : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_FULLTILE;
24520 break;
24521 case 5:
24522 (value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_TRANS_BG : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_TRANS_BG;
24523 break;
24524 case 6:
24525 (value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_TRANS_FG : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_TRANS_FG;
24526 break;
24527 default:
24528 Z_scripterrlog("Invalid index supplied to messagedata->Flags[]: %d\n", indx);
24529 break;
24530 }
24531 }
24532 break;
24533 }
24534
24535
24536
24537
24538 ///----------------------------------------------------------------------------------------------------//
24539 //combodata cd-> Setter Variables
24540 //newcombo
24541 #define SET_COMBO_VAR_INT(member, str) \
24542 { \
24543 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24544 { \
24545 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24546 } \
24547 else \
24548 { \
24549 combobuf[ri->combosref].member = vbound((value / 10000),0,214747); \
24550 } \
24551 } \
24552
24553 #define SET_COMBO_VAR_DWORD(member, str) \
24554 { \
24555 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24556 { \
24557 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24558 } \
24559 else \
24560 { \
24561 combobuf[ri->combosref].member = vbound((value / 10000),0,32767); \
24562 } \
24563 } \
24564
24565 #define SET_COMBO_VAR_BYTE(member, str) \
24566 { \
24567 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24568 { \
24569 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24570 } \
24571 else \
24572 { \
24573 combobuf[ri->combosref].member = vbound((value / 10000),0,255); \
24574 } \
24575 } \
24576
24577 #define SET_COMBO_VAR_INDEX(member, str, indexbound) \
24578 { \
24579 int32_t indx = ri->d[rINDEX] / 10000; \
24580 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24581 { \
24582 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24583 } \
24584 else if ( indx < 0 || indx >= indexbound ) \
24585 { \
24586 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
24587 } \
24588 else \
24589 { \
24590 combobuf[ri->combosref].member[indx] = vbound((value / 10000),0,214747); \
24591 } \
24592 }
24593
24594 #define SET_COMBO_VAR_INDEX2(member, str, indexbound, low, high) \
24595 { \
24596 int32_t indx = ri->d[rINDEX] / 10000; \
24597 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24598 { \
24599 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24600 } \
24601 else if ( indx < 0 || indx >= indexbound ) \
24602 { \
24603 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
24604 } \
24605 else \
24606 { \
24607 combobuf[ri->combosref].member[indx] = vbound((value / 10000),low,high); \
24608 } \
24609 }
24610
24611 #define SET_COMBO_BYTE_INDEX(member, str, indexbound) \
24612 { \
24613 int32_t indx = ri->d[rINDEX] / 10000; \
24614 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24615 { \
24616 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24617 } \
24618 else if ( indx < 0 || indx >= indexbound ) \
24619 { \
24620 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
24621 } \
24622 else \
24623 { \
24624 combobuf[ri->combosref].member[indx] = vbound((value / 10000),0,255); \
24625 } \
24626 }
24627
24628 #define SET_COMBO_FLAG(member, str) \
24629 { \
24630 int32_t flag = (value/10000); \
24631 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24632 { \
24633 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24634 } \
24635 else \
24636 { \
24637 if ( flag != 0 ) \
24638 { \
24639 combobuf[ri->combosref].member|=flag; \
24640 } \
24641 else combobuf[ri->combosref].member|= ~flag; \
24642 } \
24643 } \
24644
24645 //comboclass
24646 #define SET_COMBOCLASS_VAR_INT(member, str) \
24647 { \
24648 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24649 { \
24650 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24651 } \
24652 else \
24653 { \
24654 combo_class_buf[combobuf[ri->combosref].type].member = vbound((value / 10000),0,214747); \
24655 } \
24656 } \
24657
24658 #define SET_COMBOCLASS_VAR_DWORD(member, str) \
24659 { \
24660 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24661 { \
24662 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24663 } \
24664 else \
24665 { \
24666 combo_class_buf[combobuf[ri->combosref].type].member = vbound((value / 10000),0,32767); \
24667 } \
24668 } \
24669
24670 #define SET_COMBOCLASS_VAR_BYTE(member, str) \
24671 { \
24672 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24673 { \
24674 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24675 } \
24676 else \
24677 { \
24678 combo_class_buf[combobuf[ri->combosref].type].member = vbound((value / 10000),0,255); \
24679 } \
24680 } \
24681
24682 #define SET_COMBOCLASS_VAR_INDEX(member, str, indexbound) \
24683 { \
24684 int32_t indx = ri->d[rINDEX] / 10000; \
24685 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24686 { \
24687 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24688 } \
24689 else if ( indx < 0 || indx > indexbound ) \
24690 { \
24691 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
24692 } \
24693 else \
24694 { \
24695 combo_class_buf[combobuf[ri->combosref].type].member[indx] = vbound((value / 10000),0,214747); \
24696 } \
24697 }
24698
24699 #define SET_COMBOCLASS_BYTE_INDEX(member, str, indexbound) \
24700 { \
24701 int32_t indx = ri->d[rINDEX] / 10000; \
24702 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24703 { \
24704 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24705 } \
24706 else if ( indx < 0 || indx > indexbound ) \
24707 { \
24708 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
24709 } \
24710 else \
24711 { \
24712 combo_class_buf[combobuf[ri->combosref].type].member[indx] = vbound((value / 10000),0,255); \
24713 } \
24714 }
24715
24716 #define SET_COMBOCLASS_FLAG(member, str) \
24717 { \
24718 int32_t flag = (value/10000); \
24719 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
24720 { \
24721 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
24722 } \
24723 else \
24724 { \
24725 if ( flag != 0 ) \
24726 { \
24727 combo_class_buf[combobuf[ri->combosref].type].member|=flag; \
24728 } \
24729 else combo_class_buf[combobuf[ri->combosref].type].member|= ~flag; \
24730 } \
24731 } \
24732
24733 //NEWCOMBO STRUCT
24734 case COMBODTILE: SET_COMBO_VAR_INT(tile, "Tile"); break; //word
24735 case COMBODOTILE:
24736 {
24737 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24738 {
24739 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "OriginalTile");
24740 }
24741 else
24742 {
24743 newcombo& cdata = combobuf[ri->combosref];
24744 cdata.o_tile = vbound((value / 10000),0,NEWMAXTILES);
24745 if(get_qr(qr_NEW_COMBO_ANIMATION))
24746 {
24747 cdata.tile = cdata.o_tile + ((1+cdata.skipanim)*cdata.cur_frame);
24748 if(int32_t rowoffset = TILEROW(cdata.tile)-TILEROW(cdata.o_tile))
24749 {
24750 cdata.tile += cdata.skipanimy * rowoffset * TILES_PER_ROW;
24751 }
24752 }
24753 }
24754 break;
24755 }
24756 case COMBODFRAME: SET_COMBO_VAR_BYTE(cur_frame, "Frame"); break; //char
24757 case COMBODACLK: SET_COMBO_VAR_BYTE(aclk, "AClk"); break; //char
24758 case COMBODATASCRIPT: SET_COMBO_VAR_DWORD(script, "Script"); break; //word
24759 case COMBODASPEED: SET_COMBO_VAR_BYTE(speed, "ASpeed"); break; //char
24760 case COMBODFLIP: SET_COMBO_VAR_BYTE(flip, "Flip"); break; //char
24761 case COMBODWALK:
24762 {
24763 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24764 {
24765 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Walk");
24766 }
24767 else
24768 {
24769 combobuf[ri->combosref].walk &= ~0x0F;
24770 combobuf[ri->combosref].walk |= (value / 10000)&0x0F;
24771 }
24772 break;
24773 }
24774 case COMBODEFFECT:
24775 {
24776 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24777 {
24778 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Effect");
24779 }
24780 else
24781 {
24782 combobuf[ri->combosref].walk &= ~0xF0;
24783 combobuf[ri->combosref].walk |= ((value / 10000)&0x0F)<<4;
24784 }
24785 break;
24786 }
24787 case COMBODTYPE:
24788 {
24789 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24790 {
24791 Z_scripterrlog("Invalid Combo ID passed to combodata->Type: %d\n", (ri->combosref*10000));
24792 }
24793 else
24794 {
24795 screen_combo_modify_pre(ri->combosref);
24796 combobuf[ri->combosref].type = vbound((value / 10000),0,255);
24797 screen_combo_modify_post(ri->combosref);
24798 }
24799 break;
24800 }
24801 case COMBODCSET:
24802 {
24803 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24804 {
24805 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "CSet2");
24806 }
24807 else
24808 {
24809 int8_t v = vbound(value, -8, 7);
24810 combobuf[ri->combosref].csets &= ~0xF;
24811 combobuf[ri->combosref].csets |= v;
24812 }
24813 break;
24814 }
24815 case COMBODCSET2FLAGS:
24816 {
24817 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24818 {
24819 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "CSet2Flags");
24820 }
24821 else
24822 {
24823 combobuf[ri->combosref].csets &= 0xF;
24824 combobuf[ri->combosref].csets |= (value&0xF)<<4;
24825 }
24826 break;
24827 }
24828 case COMBODFOO: break; //W
24829 case COMBODFRAMES: SET_COMBO_VAR_BYTE(frames, "Frames"); break; //C
24830 case COMBODNEXTD: SET_COMBO_VAR_DWORD(speed, "NextData"); break; //W
24831 case COMBODNEXTC: SET_COMBO_VAR_BYTE(nextcombo, "NextCSet"); break; //C
24832 case COMBODFLAG: SET_COMBO_VAR_BYTE(nextcset, "Flag"); break; //C
24833 case COMBODSKIPANIM: SET_COMBO_VAR_BYTE(skipanim, "SkipAnim"); break; //C
24834 case COMBODNEXTTIMER: SET_COMBO_VAR_DWORD(nexttimer, "NextTimer"); break; //W
24835 case COMBODAKIMANIMY: SET_COMBO_VAR_BYTE(skipanimy, "SkipAnimY"); break; //C
24836 case COMBODANIMFLAGS: SET_COMBO_VAR_BYTE(animflags, "AnimFlags"); break; //C
24837 case COMBODEXPANSION: SET_COMBO_BYTE_INDEX(expansion, "Expansion[]", 6); break; //C , 6 INDICES
24838 case COMBODATTRIBUTES:
24839 {
24840 int32_t indx = ri->d[rINDEX] / 10000;
24841 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24842 {
24843 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Attributes[]");
24844 }
24845 else if ( indx < 0 || indx > 4 )
24846 {
24847 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "Attributes[]");
24848 }
24849 else
24850 {
24851 combobuf[ri->combosref].attributes[indx] = value;
24852 }
24853 }break;
24854 //case COMBODATAINITD: SET_COMBO_VAR_INDEX(initd, "InitD[]", 2); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
24855 case COMBODATAINITD:
24856 {
24857 int32_t indx = ri->d[rINDEX] / 10000;
24858 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24859 {
24860 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "InitD[]");
24861 }
24862 else if ( ((unsigned)indx) > 8 )
24863 {
24864 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "InitD[]");
24865 }
24866 else
24867 {
24868 combobuf[ri->combosref].initd[indx] = (value * ( get_qr(qr_COMBODATA_INITD_MULT_TENK) ? 10000 : 1));
24869 }
24870 break;
24871 }
24872
24873
24874 case COMBODATTRIBYTES: SET_COMBO_VAR_INDEX(attribytes, "Attribytes[]", 8); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
24875 case COMBODATTRISHORTS: SET_COMBO_VAR_INDEX2(attrishorts, "Attrishorts[]", 8, -32768, 32767); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
24876 case COMBODUSRFLAGARR:
24877 {
24878 int32_t indx = ri->d[rINDEX] / 10000;
24879 if (ri->combosref < 0 || ri->combosref >(MAXCOMBOS - 1))
24880 {
24881 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", "Flags[]", (ri->combosref * 10000));
24882 }
24883 else if (((unsigned)indx) > 15)
24884 {
24885 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", "Flags[]", indx);
24886 }
24887 else
24888 {
24889 SETFLAG(combobuf[ri->combosref].usrflags, 1 << indx, value);
24890 }
24891 break;
24892 }
24893 case COMBODGENFLAGARR:
24894 {
24895 int32_t indx = ri->d[rINDEX] / 10000;
24896 if (ri->combosref < 0 || ri->combosref >(MAXCOMBOS - 1))
24897 {
24898 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", "GenFlags[]", (ri->combosref * 10000));
24899 }
24900 else if (((unsigned)indx) > 0)
24901 {
24902 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", "GenFlags[]", indx);
24903 }
24904 else
24905 {
24906 SETFLAG(combobuf[ri->combosref].genflags, 1 << indx, value);
24907 }
24908 break;
24909 }
24910 case COMBODUSRFLAGS: SET_COMBO_VAR_INT(usrflags, "UserFlags"); break; //LONG
24911 case COMBODTRIGGERFLAGS: SET_COMBO_VAR_INDEX(triggerflags, "TriggerFlags[]", 6); break; //LONG 3 INDICES AS FLAGSETS
24912 case COMBODTRIGGERFLAGS2:
24913 {
24914 int32_t indx = ri->d[rINDEX] / 10000;
24915 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24916 {
24917 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TrigFlags[]");
24918 }
24919 else if ( unsigned(indx) >= 32*6 )
24920 {
24921 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "TrigFlags[]");
24922 }
24923 else
24924 {
24925 SETFLAG(combobuf[ri->combosref].triggerflags[indx/32],1<<(indx%32),value);
24926 }
24927 break;
24928 }
24929 case COMBODTRIGGERBUTTON:
24930 {
24931 int32_t indx = ri->d[rINDEX] / 10000;
24932 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24933 {
24934 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerButton[]");
24935 }
24936 else if ( unsigned(indx) >= 8 )
24937 {
24938 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "TriggerButton[]");
24939 }
24940 else
24941 {
24942 SETFLAG(combobuf[ri->combosref].triggerbtn,1<<indx,value);
24943 }
24944 break;
24945 }
24946 case COMBODTRIGGERITEM:
24947 {
24948 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24949 {
24950 Z_scripterrlog("Invalueid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerItem");
24951 }
24952 else combobuf[ri->combosref].triggeritem = vbound(value/10000,0,255);
24953 break;
24954 }
24955 case COMBODTRIGGERTIMER:
24956 {
24957 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24958 {
24959 Z_scripterrlog("Invalueid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerTimer");
24960 }
24961 else combobuf[ri->combosref].trigtimer = vbound(value/10000,0,255);
24962 break;
24963 }
24964 case COMBODTRIGGERSFX:
24965 {
24966 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24967 {
24968 Z_scripterrlog("Invalueid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerSFX");
24969 }
24970 else combobuf[ri->combosref].trigsfx = vbound(value/10000,0,255);
24971 break;
24972 }
24973 case COMBODTRIGGERCHANGECMB:
24974 {
24975 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24976 {
24977 Z_scripterrlog("Invalueid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerChange");
24978 }
24979 else combobuf[ri->combosref].trigchange = vbound(value/10000,-65535,65535);
24980 break;
24981 }
24982 case COMBODTRIGGERPROX:
24983 {
24984 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24985 {
24986 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerProximity");
24987 }
24988 else combobuf[ri->combosref].trigprox = vbound(value/10000,0,65535);
24989 break;
24990 }
24991 case COMBODTRIGGERLIGHTBEAM:
24992 {
24993 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
24994 {
24995 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerLightBeam");
24996 }
24997 else combobuf[ri->combosref].triglbeam = vbound(value/10000,0,32);
24998 break;
24999 }
25000 case COMBODTRIGGERCTR:
25001 {
25002 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25003 {
25004 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerCounter");
25005 }
25006 else combobuf[ri->combosref].trigctr = vbound(value/10000, 0, MAX_COUNTERS-1);
25007 break;
25008 }
25009 case COMBODTRIGGERCTRAMNT:
25010 {
25011 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25012 {
25013 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerCtrAmount");
25014 }
25015 else combobuf[ri->combosref].trigctramnt = vbound(value/10000, -65535, 65535);
25016 break;
25017 }
25018
25019 case COMBODTRIGGERCOOLDOWN:
25020 {
25021 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25022 {
25023 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerCooldown: %d\n", (ri->combosref*10000));
25024 }
25025 else combobuf[ri->combosref].trigcooldown = vbound(value/10000, 0, 255);
25026 break;
25027 }
25028 case COMBODTRIGGERCOPYCAT:
25029 {
25030 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25031 {
25032 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerCopycat: %d\n", (ri->combosref*10000));
25033 }
25034 else combobuf[ri->combosref].trigcopycat = vbound(value/10000, 0, 255);
25035 break;
25036 }
25037 case COMBODTRIGITEMPICKUP:
25038 {
25039 const int32_t allowed_pflags = ipHOLDUP | ipTIMER | ipSECRETS | ipCANGRAB;
25040 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25041 {
25042 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerSpawnItemPickup: %d\n", (ri->combosref*10000));
25043 }
25044 else combobuf[ri->combosref].spawnip = (value/10000)&allowed_pflags;
25045 break;
25046 }
25047 case COMBODTRIGEXSTATE:
25048 {
25049 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25050 {
25051 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigExState: %d\n", (ri->combosref*10000));
25052 }
25053 else combobuf[ri->combosref].exstate = vbound(value/10000, -1, 31);
25054 break;
25055 }
25056 case COMBODTRIGSPAWNENEMY:
25057 {
25058 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25059 {
25060 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigSpawnEnemy: %d\n", (ri->combosref*10000));
25061 }
25062 else combobuf[ri->combosref].spawnenemy = vbound(value/10000, 0, 511);
25063 break;
25064 }
25065 case COMBODTRIGSPAWNITEM:
25066 {
25067 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25068 {
25069 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigSpawnItem: %d\n", (ri->combosref*10000));
25070 }
25071 else combobuf[ri->combosref].spawnitem = vbound(value/10000, -255, 255);
25072 break;
25073 }
25074 case COMBODTRIGCSETCHANGE:
25075 {
25076 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25077 {
25078 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigCSetChange: %d\n", (ri->combosref*10000));
25079 }
25080 else combobuf[ri->combosref].trigcschange = vbound(value/10000, -15, 15);
25081 break;
25082 }
25083 case COMBODLIFTGFXCOMBO:
25084 {
25085 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25086 {
25087 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXCombo: %d\n", (ri->combosref*10000));
25088 }
25089 else combobuf[ri->combosref].liftcmb = vbound(value/10000, 0, MAXCOMBOS);
25090 break;
25091 }
25092 case COMBODLIFTGFXCCSET:
25093 {
25094 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25095 {
25096 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXCSet: %d\n", (ri->combosref*10000));
25097 }
25098 else combobuf[ri->combosref].liftcs = vbound(value/10000, 0, 13);
25099 break;
25100 }
25101 case COMBODLIFTUNDERCMB:
25102 {
25103 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25104 {
25105 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftUnderCombo: %d\n", (ri->combosref*10000));
25106 }
25107 else combobuf[ri->combosref].liftundercmb = vbound(value/10000, 0, MAXCOMBOS);
25108 break;
25109 }
25110 case COMBODLIFTUNDERCS:
25111 {
25112 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25113 {
25114 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftUnderCSet: %d\n", (ri->combosref*10000));
25115 }
25116 else combobuf[ri->combosref].liftundercs = vbound(value/10000, 0, 13);
25117 break;
25118 }
25119 case COMBODLIFTDAMAGE:
25120 {
25121 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25122 {
25123 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftDamage: %d\n", (ri->combosref*10000));
25124 }
25125 else combobuf[ri->combosref].liftdmg = vbound(value/10000, 0, 255);
25126 break;
25127 }
25128 case COMBODLIFTLEVEL:
25129 {
25130 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25131 {
25132 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftLevel: %d\n", (ri->combosref*10000));
25133 }
25134 else combobuf[ri->combosref].liftlvl = vbound(value/10000, 0, 255);
25135 break;
25136 }
25137 case COMBODLIFTITEM:
25138 {
25139 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25140 {
25141 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftItem: %d\n", (ri->combosref*10000));
25142 }
25143 else combobuf[ri->combosref].liftitm = vbound(value/10000, 0, 255);
25144 break;
25145 }
25146 case COMBODLIFTFLAGS:
25147 {
25148 int32_t indx = ri->d[rINDEX] / 10000;
25149 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25150 {
25151 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftFlags[]: %d\n", (ri->combosref*10000));
25152 break;
25153 }
25154 if ( unsigned(indx) > 7 )
25155 {
25156 Z_scripterrlog("Invalid index supplied to combodata->LiftFlags[]: %d\n", indx);
25157 break;
25158 }
25159 SETFLAG(combobuf[ri->combosref].liftflags, (1<<indx), value);
25160 break;
25161 }
25162 case COMBODLIFTGFXTYPE:
25163 {
25164 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25165 {
25166 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXType: %d\n", (ri->combosref*10000));
25167 }
25168 else combobuf[ri->combosref].liftgfx = vbound(value/10000, 0, 2);
25169 break;
25170 }
25171 case COMBODLIFTGFXSPRITE:
25172 {
25173 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25174 {
25175 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXSprite: %d\n", (ri->combosref*10000));
25176 }
25177 else combobuf[ri->combosref].liftsprite = vbound(value/10000, 0, 255);
25178 break;
25179 }
25180 case COMBODLIFTSFX:
25181 {
25182 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25183 {
25184 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftSFX: %d\n", (ri->combosref*10000));
25185 }
25186 else combobuf[ri->combosref].liftsfx = vbound(value/10000, 0, 255);
25187 break;
25188 }
25189 case COMBODLIFTBREAKSPRITE:
25190 {
25191 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25192 {
25193 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftBreakSprite: %d\n", (ri->combosref*10000));
25194 }
25195 else combobuf[ri->combosref].liftbreaksprite = vbound(value/10000, -4, 255);
25196 break;
25197 }
25198 case COMBODLIFTBREAKSFX:
25199 {
25200 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25201 {
25202 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftBreakSFX: %d\n", (ri->combosref*10000));
25203 }
25204 else combobuf[ri->combosref].liftbreaksfx = vbound(value/10000, 0, 255);
25205 break;
25206 }
25207 case COMBODLIFTHEIGHT:
25208 {
25209 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25210 {
25211 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftHeight: %d\n", (ri->combosref*10000));
25212 }
25213 else combobuf[ri->combosref].lifthei = vbound(value/10000, 0, 255);
25214 break;
25215 }
25216 case COMBODLIFTTIME:
25217 {
25218 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25219 {
25220 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftTime: %d\n", (ri->combosref*10000));
25221 }
25222 else combobuf[ri->combosref].lifttime = vbound(value/10000, 0, 255);
25223 break;
25224 }
25225 case COMBODLIFTWEAPONITEM:
25226 {
25227 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25228 {
25229 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftWeaponItem: %d\n", (ri->combosref*10000));
25230 }
25231 else combobuf[ri->combosref].lift_parent_item = vbound(value/10000, 0, 255);
25232 break;
25233 }
25234 case COMBODTRIGGERLSTATE:
25235 {
25236 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25237 {
25238 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigLevelState: %d\n", (ri->combosref*10000));
25239 }
25240 else combobuf[ri->combosref].trig_lstate = vbound(value/10000, 0, 31);
25241 break;
25242 }
25243 case COMBODTRIGGERGSTATE:
25244 {
25245 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25246 {
25247 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGlobalState: %d\n", (ri->combosref*10000));
25248 }
25249 else combobuf[ri->combosref].trig_gstate = vbound(value/10000, 0, 255);
25250 break;
25251 }
25252 case COMBODTRIGGERGROUP:
25253 {
25254 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25255 {
25256 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGroup: %d\n", (ri->combosref*10000));
25257 }
25258 else combobuf[ri->combosref].trig_group = vbound(value/10000, 0, 255);
25259 break;
25260 }
25261 case COMBODTRIGGERGROUPVAL:
25262 {
25263 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25264 {
25265 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGroupVal: %d\n", (ri->combosref*10000));
25266 }
25267 else combobuf[ri->combosref].trig_group_val = vbound(value/10000, 0, 65535);
25268 break;
25269 }
25270 case COMBODTRIGGERGTIMER:
25271 {
25272 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25273 {
25274 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGStateTimer: %d\n", (ri->combosref*10000));
25275 }
25276 else combobuf[ri->combosref].trig_statetime = vbound(value/10000, 0, 214748);
25277 break;
25278 }
25279 case COMBODTRIGGERGENSCRIPT:
25280 {
25281 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
25282 {
25283 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGenScript: %d\n", (ri->combosref*10000));
25284 }
25285 else combobuf[ri->combosref].trig_genscr = vbound(value/10000, 0, 65535);
25286 break;
25287 }
25288 case COMBODTRIGGERLEVEL: SET_COMBO_VAR_INT(triggerlevel, "TriggerLevel"); break; //LONG
25289
25290
25291
25292
25293
25294 //COMBOCLASS STRUCT
25295 //case COMBODNAME: //CHAR[64], STRING
25296 case COMBODBLOCKNPC: SET_COMBOCLASS_VAR_BYTE(block_enemies, "BlockNPC"); break; //C
25297 case COMBODBLOCKHOLE: SET_COMBOCLASS_VAR_BYTE(block_hole, "BlockHole"); break; //C
25298 case COMBODBLOCKTRIG: SET_COMBOCLASS_VAR_BYTE(block_trigger, "BlockTrigger"); break; //C
25299 case COMBODBLOCKWEAPON: SET_COMBOCLASS_BYTE_INDEX(block_weapon, "BlockWeapon[]", 32); break; //C, 32 INDICES
25300 case COMBODCONVXSPEED: SET_COMBOCLASS_VAR_DWORD(conveyor_x_speed, "ConveyorSpeedX"); break; //SHORT
25301 case COMBODCONVYSPEED: SET_COMBOCLASS_VAR_DWORD(conveyor_y_speed, "ConveyorSpeedY"); break; //SHORT
25302 case COMBODSPAWNNPC: SET_COMBOCLASS_VAR_DWORD(create_enemy, "SpawnNPC"); break; //W
25303 case COMBODSPAWNNPCWHEN: SET_COMBOCLASS_VAR_BYTE(create_enemy_when, "SpawnNPCWhen"); break; //C
25304 case COMBODSPAWNNPCCHANGE: SET_COMBOCLASS_VAR_INT(create_enemy_change, "SpawnNPCChange"); break; //LONG
25305 case COMBODDIRCHANGETYPE: SET_COMBOCLASS_VAR_BYTE(directional_change_type, "DirChange"); break; //C
25306 case COMBODDISTANCECHANGETILES: SET_COMBOCLASS_VAR_INT(distance_change_tiles, "DistanceChangeTiles"); break; //LONG
25307 case COMBODDIVEITEM: SET_COMBOCLASS_VAR_DWORD(dive_item, "DiveItem"); break; //SHORT
25308 case COMBODDOCK: SET_COMBOCLASS_VAR_BYTE(dock, "Dock"); break; //C
25309 case COMBODFAIRY: SET_COMBOCLASS_VAR_BYTE(fairy, "Fairy"); break; //C
25310 case COMBODFFATTRCHANGE: SET_COMBOCLASS_VAR_BYTE(ff_combo_attr_change, "FFCAttributeChange"); break; //C
25311 case COMBODFOORDECOTILE: SET_COMBOCLASS_VAR_INT(foot_decorations_tile, "DecorationTile"); break; //LONG
25312 case COMBODFOORDECOTYPE: SET_COMBOCLASS_VAR_BYTE(foot_decorations_type, "DecorationType"); break; //C
25313 case COMBODHOOKSHOTPOINT: SET_COMBOCLASS_VAR_BYTE(hookshot_grab_point, "Hookshot"); break; //C
25314 case COMBODLADDERPASS: SET_COMBOCLASS_VAR_BYTE(ladder_pass, "Ladder"); break; //C
25315 case COMBODLOCKBLOCK: SET_COMBOCLASS_VAR_BYTE(lock_block_type, "LockBlock"); break; //C
25316 case COMBODLOCKBLOCKCHANGE: SET_COMBOCLASS_VAR_INT(lock_block_change, "LockBlockChange"); break; //LONG
25317 case COMBODMAGICMIRROR: SET_COMBOCLASS_VAR_BYTE(magic_mirror_type, "Mirror"); break; //C
25318 case COMBODMODHPAMOUNT: SET_COMBOCLASS_VAR_DWORD(modify_hp_amount, "DamageAmount"); break; //SHORT
25319 case COMBODMODHPDELAY: SET_COMBOCLASS_VAR_BYTE(modify_hp_delay, "DamageDelay"); break; //C
25320 case COMBODMODHPTYPE: SET_COMBOCLASS_VAR_BYTE(modify_hp_type, "DamageType"); break; //C
25321 case COMBODNMODMPAMOUNT: SET_COMBOCLASS_VAR_DWORD(modify_mp_amount, "MagicAmount"); break; //SHORT
25322 case COMBODMODMPDELAY: SET_COMBOCLASS_VAR_BYTE(modify_mp_delay, "MagicDelay"); break; //C
25323 case COMBODMODMPTYPE: SET_COMBOCLASS_VAR_BYTE(modify_mp_type, "MagicType"); break; //C
25324 case COMBODNOPUSHBLOCK: SET_COMBOCLASS_VAR_BYTE(no_push_blocks, "NoPushBlocks"); break; //C
25325 case COMBODOVERHEAD: SET_COMBOCLASS_VAR_BYTE(overhead, "Overhead"); break; //C
25326 case COMBODPLACENPC: SET_COMBOCLASS_VAR_BYTE(place_enemy, "PlaceNPC"); break; //C
25327 case COMBODPUSHDIR: SET_COMBOCLASS_VAR_BYTE(push_direction, "PushDir"); break; //C
25328 case COMBODPUSHWAIT: SET_COMBOCLASS_VAR_BYTE(push_wait, "PushDelay"); break; //C
25329 case COMBODPUSHHEAVY: SET_COMBOCLASS_VAR_BYTE(push_weight, "PushHeavy"); break; //C
25330 case COMBODPUSHED: SET_COMBOCLASS_VAR_BYTE(pushed, "Pushed"); break; //C
25331 case COMBODRAFT: SET_COMBOCLASS_VAR_BYTE(raft, "Raft"); break; //C
25332 case COMBODRESETROOM: SET_COMBOCLASS_VAR_BYTE(reset_room, "ResetRoom"); break; //C
25333 case COMBODSAVEPOINTTYPE: SET_COMBOCLASS_VAR_BYTE(save_point_type, "SavePoint"); break; //C
25334 case COMBODSCREENFREEZETYPE: SET_COMBOCLASS_VAR_BYTE(screen_freeze_type, "FreezeScreen"); break; //C
25335 case COMBODSECRETCOMBO: SET_COMBOCLASS_VAR_BYTE(secret_combo, "SecretCombo"); break; //C
25336 case COMBODSINGULAR: SET_COMBOCLASS_VAR_BYTE(singular, "Singular"); break; //C
25337 case COMBODSLOWWALK: SET_COMBOCLASS_VAR_BYTE(slow_movement, "SlowWalk"); break; //C
25338 case COMBODSTATUETYPE: SET_COMBOCLASS_VAR_BYTE(statue_type, "Statue"); break; //C
25339 case COMBODSTEPTYPE: SET_COMBOCLASS_VAR_BYTE(step_type, "Step"); break; //C
25340 case COMBODSTEPCHANGEINTO: SET_COMBOCLASS_VAR_INT(step_change_to, "StepChange"); break; //LONG
25341 case COMBODSTRIKEWEAPONS: SET_COMBOCLASS_BYTE_INDEX(strike_weapons, "Strike[]", 32); break; //BYTE, 32 INDICES.
25342 case COMBODSTRIKEREMNANTS: SET_COMBOCLASS_VAR_INT(strike_remnants, "StrikeRemnants"); break; //LONG
25343 case COMBODSTRIKEREMNANTSTYPE: SET_COMBOCLASS_VAR_BYTE(strike_remnants_type, "StrikeRemnantsType"); break; //C
25344 case COMBODSTRIKECHANGE: SET_COMBOCLASS_VAR_INT(strike_change, "StrikeChange"); break; //LONG
25345 case COMBODSTRIKEITEM: SET_COMBOCLASS_VAR_DWORD(strike_item, "StrikeItem"); break; //SHORT
25346 case COMBODTOUCHITEM: SET_COMBOCLASS_VAR_DWORD(touch_item, "TouchItem"); break; //SHORT
25347 case COMBODTOUCHSTAIRS: SET_COMBOCLASS_VAR_BYTE(touch_stairs, "TouchStairs"); break; //C
25348 case COMBODTRIGGERTYPE: SET_COMBOCLASS_VAR_BYTE(trigger_type, "TriggerType"); break; //C
25349 case COMBODTRIGGERSENS: SET_COMBOCLASS_VAR_BYTE(trigger_sensitive, "TriggerSensitivity"); break; //C
25350 case COMBODWARPTYPE: SET_COMBOCLASS_VAR_BYTE(warp_type, "Warp"); break; //C
25351 case COMBODWARPSENS: SET_COMBOCLASS_VAR_BYTE(warp_sensitive, "WarpSensitivity"); break; //C
25352 case COMBODWARPDIRECT: SET_COMBOCLASS_VAR_BYTE(warp_direct, "WarpDirect"); break; //C
25353 case COMBODWARPLOCATION: SET_COMBOCLASS_VAR_BYTE(warp_location, "WarpLocation"); break; //C
25354 case COMBODWATER: SET_COMBOCLASS_VAR_BYTE(water, "Liquid"); break; //C
25355 case COMBODWHISTLE: SET_COMBOCLASS_VAR_BYTE(whistle, "Whistle"); break; //C
25356 case COMBODWINGAME: SET_COMBOCLASS_VAR_BYTE(win_game, "WinGame"); break; //C
25357 case COMBODBLOCKWPNLEVEL: SET_COMBOCLASS_VAR_BYTE(block_weapon_lvl, "BlockWeaponLevel"); break; //C
25358
25359
25360
25361 ///----------------------------------------------------------------------------------------------------//
25362 //npcdata nd-> Variables
25363
25364 #define SET_NPCDATA_VAR_INT(member, str) \
25365 { \
25366 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
25367 { \
25368 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
25369 } \
25370 else \
25371 { \
25372 guysbuf[ri->npcdataref].member = vbound((value / 10000),0,214747); \
25373 } \
25374 } \
25375
25376 #define SET_NPCDATA_VAR_DWORD(member, str) \
25377 { \
25378 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
25379 { \
25380 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
25381 } \
25382 else \
25383 { \
25384 guysbuf[ri->npcdataref].member = vbound((value / 10000),0,32767); \
25385 } \
25386 } \
25387
25388 #define SET_NPCDATA_VAR_BYTE(member, str) \
25389 { \
25390 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
25391 { \
25392 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
25393 } \
25394 else \
25395 { \
25396 guysbuf[ri->npcdataref].member = vbound((value / 10000),0,255); \
25397 } \
25398 } \
25399
25400 #define SET_NPCDATA_VAR_INDEX(member, str, indexbound) \
25401 { \
25402 int32_t indx = ri->d[rINDEX] / 10000; \
25403 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
25404 { \
25405 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
25406 } \
25407 else if ( (unsigned)indx > indexbound ) \
25408 { \
25409 Z_scripterrlog("Invalid Array Index passed to npcdata->%s: %d\n", indx, str); \
25410 } \
25411 else \
25412 { \
25413 guysbuf[ri->npcdataref].member[indx] = vbound((value / 10000),0,214747); \
25414 } \
25415 }
25416
25417 #define SET_NPCDATA_BYTE_INDEX(member, str, indexbound) \
25418 { \
25419 int32_t indx = ri->d[rINDEX] / 10000; \
25420 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
25421 { \
25422 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
25423 } \
25424 else if ( (unsigned)indx > indexbound ) \
25425 { \
25426 Z_scripterrlog("Invalid Array Index passed to npcdata->%s: %d\n", indx, str); \
25427 } \
25428 else \
25429 { \
25430 guysbuf[ri->npcdataref].member[indx] = vbound((value / 10000),0,255); \
25431 } \
25432 }
25433
25434 #define SET_NPCDATA_FLAG(member, str) \
25435 { \
25436 int32_t flag = (value/10000); \
25437 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
25438 { \
25439 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
25440 } \
25441 else \
25442 { \
25443 if ( flag ) \
25444 { \
25445 guysbuf[ri->npcdataref].member|=flag; \
25446 } \
25447 else guysbuf[ri->npcdataref].member|= ~flag; \
25448 } \
25449 } \
25450
25451 case NPCDATATILE: SET_NPCDATA_VAR_BYTE(tile, "Tile"); break;
25452 case NPCDATAWIDTH: SET_NPCDATA_VAR_BYTE(width, "Width"); break;
25453 case NPCDATAHEIGHT: SET_NPCDATA_VAR_BYTE(height, "Height"); break;
25454 case NPCDATAFLAGS: SET_NPCDATA_VAR_DWORD(flags, "Flags"); break; //16 b its
25455 case NPCDATAFLAGS2: SET_NPCDATA_VAR_DWORD(flags2, "Flags2"); break; //16 bits
25456 case NPCDATASTILE: SET_NPCDATA_VAR_BYTE(s_tile, "STile"); break;
25457 case NPCDATASWIDTH: SET_NPCDATA_VAR_BYTE(s_width, "SWidth"); break;
25458 case NPCDATASHEIGHT: SET_NPCDATA_VAR_BYTE(s_height, "SHeight"); break;
25459 case NPCDATAETILE: SET_NPCDATA_VAR_INT(e_tile, "ExTile"); break;
25460 case NPCDATAEWIDTH: SET_NPCDATA_VAR_BYTE(e_width, "ExWidth"); break;
25461 case NPCDATASCRIPT: SET_NPCDATA_VAR_BYTE(script, "Script"); break;
25462 case NPCDATAEHEIGHT: SET_NPCDATA_VAR_BYTE(e_height, "ExHeight"); break;
25463 case NPCDATAHP: SET_NPCDATA_VAR_DWORD(hp, "HP"); break;
25464 case NPCDATAFAMILY: SET_NPCDATA_VAR_DWORD(family, "Family"); break;
25465 case NPCDATACSET: SET_NPCDATA_VAR_DWORD(cset, "CSet"); break;
25466 case NPCDATAANIM: SET_NPCDATA_VAR_DWORD(anim, "Anim"); break;
25467 case NPCDATAEANIM: SET_NPCDATA_VAR_DWORD(e_anim, "ExAnim"); break;
25468 case NPCDATAFRAMERATE: SET_NPCDATA_VAR_DWORD(frate, "Framerate"); break;
25469 case NPCDATAEFRAMERATE: SET_NPCDATA_VAR_DWORD(e_frate, "ExFramerate"); break;
25470 case NPCDATATOUCHDAMAGE: SET_NPCDATA_VAR_DWORD(dp, "TouchDamage"); break;
25471 case NPCDATAWEAPONDAMAGE: SET_NPCDATA_VAR_DWORD(wdp, "WeaponDamage"); break;
25472 case NPCDATAWEAPON: SET_NPCDATA_VAR_DWORD(weapon, "Weapon"); break;
25473 case NPCDATARANDOM: SET_NPCDATA_VAR_DWORD(rate, "Random"); break;
25474 case NPCDATAHALT: SET_NPCDATA_VAR_DWORD(hrate, "Haltrate"); break;
25475 case NPCDATASTEP: SET_NPCDATA_VAR_DWORD(step, "Step"); break;
25476 case NPCDATAHOMING: SET_NPCDATA_VAR_DWORD(homing, "Homing"); break;
25477 case NPCDATAHUNGER: SET_NPCDATA_VAR_DWORD(grumble, "Hunger"); break;
25478 case NPCDATADROPSET: SET_NPCDATA_VAR_DWORD(item_set, "Dropset"); break;
25479 case NPCDATABGSFX: SET_NPCDATA_VAR_DWORD(bgsfx, "BGSFX"); break;
25480 case NPCDATADEATHSFX: SET_NPCDATA_VAR_BYTE(deadsfx, "DeathSFX"); break;
25481 case NPCDATAHITSFX: SET_NPCDATA_VAR_BYTE(hitsfx, "HitSFX"); break;
25482 case NPCDATAXOFS: SET_NPCDATA_VAR_INT(xofs, "DrawXOffset"); break;
25483 case NPCDATAYOFS: SET_NPCDATA_VAR_INT(yofs, "DrawYOffset"); break;
25484 case NPCDATAZOFS: SET_NPCDATA_VAR_INT(zofs, "DrawZOffset"); break;
25485 case NPCDATAHXOFS: SET_NPCDATA_VAR_INT(hxofs, "HitXOffset"); break;
25486 case NPCDATAHYOFS: SET_NPCDATA_VAR_INT(hyofs, "HitYOffset"); break;
25487 case NPCDATAHITWIDTH: SET_NPCDATA_VAR_INT(hxsz, "HitWidth"); break;
25488 case NPCDATAHITHEIGHT: SET_NPCDATA_VAR_INT(hysz, "HitHeight"); break;
25489 case NPCDATAHITZ: SET_NPCDATA_VAR_INT(hzsz, "HitZHeight"); break;
25490 case NPCDATATILEWIDTH: SET_NPCDATA_VAR_INT(txsz, "TileWidth"); break;
25491 case NPCDATATILEHEIGHT: SET_NPCDATA_VAR_INT(tysz, "TileHeight"); break;
25492 case NPCDATAWPNSPRITE: SET_NPCDATA_VAR_INT(wpnsprite, "WeaponSprite"); break;
25493 case NPCDATAWEAPONSCRIPT: SET_NPCDATA_VAR_INT(weaponscript, "WeaponScript"); break;
25494 case NPCDATADEFENSE: SET_NPCDATA_VAR_INDEX(defense, "Defense", 42); break;
25495 case NPCDATAWEAPONINITD: SET_NPCDATA_VAR_INDEX(weap_initiald, "WeaponInitD", 8); break;
25496 case NPCDATAINITD: SET_NPCDATA_VAR_INDEX(initD, "InitD", 8); break;
25497 case NPCDATASIZEFLAG: SET_NPCDATA_VAR_INT(SIZEflags, "SizeFlags"); break;
25498
25499 case NPCDATAFROZENTILE: SET_NPCDATA_VAR_INT(frozentile, "FrozenTile"); break;
25500 case NPCDATAFROZENCSET: SET_NPCDATA_VAR_INT(frozencset, "FrozenCSet"); break;
25501
25502 case NPCDATAATTRIBUTE:
25503 {
25504 int32_t indx = ri->d[rINDEX] / 10000;
25505 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
25506 {
25507 Z_scripterrlog("Invalid Sprite ID passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
25508 }
25509 else if ( indx < 0 || indx > MAX_NPC_ATRIBUTES )
25510 {
25511 Z_scripterrlog("Invalid Array Index passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
25512 }
25513 else
25514 {
25515 switch(indx)
25516 {
25517 case 0: guysbuf[ri->npcdataref].misc1 = (value / 10000); break;
25518 case 1: guysbuf[ri->npcdataref].misc2 = (value / 10000); break;
25519 case 2: guysbuf[ri->npcdataref].misc3 = (value / 10000); break;
25520 case 3: guysbuf[ri->npcdataref].misc4 = (value / 10000); break;
25521 case 4: guysbuf[ri->npcdataref].misc5 = (value / 10000); break;
25522 case 5: guysbuf[ri->npcdataref].misc6 = (value / 10000); break;
25523 case 6: guysbuf[ri->npcdataref].misc7 = (value / 10000); break;
25524 case 7: guysbuf[ri->npcdataref].misc8 = (value / 10000); break;
25525 case 8: guysbuf[ri->npcdataref].misc9 = (value / 10000); break;
25526 case 9: guysbuf[ri->npcdataref].misc10 = (value / 10000); break;
25527 case 10: guysbuf[ri->npcdataref].misc11 = (value / 10000); break;
25528 case 11: guysbuf[ri->npcdataref].misc12 = (value / 10000); break;
25529 case 12: guysbuf[ri->npcdataref].misc13 = (value / 10000); break;
25530 case 13: guysbuf[ri->npcdataref].misc14 = (value / 10000); break;
25531 case 14: guysbuf[ri->npcdataref].misc15 = (value / 10000); break;
25532
25533 case 15: guysbuf[ri->npcdataref].misc16 = value / 10000; break;
25534 case 16: guysbuf[ri->npcdataref].misc17 = value / 10000; break;
25535 case 17: guysbuf[ri->npcdataref].misc18 = value / 10000; break;
25536 case 18: guysbuf[ri->npcdataref].misc19 = value / 10000; break;
25537 case 19: guysbuf[ri->npcdataref].misc20 = value / 10000; break;
25538 case 20: guysbuf[ri->npcdataref].misc21 = value / 10000; break;
25539 case 21: guysbuf[ri->npcdataref].misc22 = value / 10000; break;
25540 case 22: guysbuf[ri->npcdataref].misc23 = value / 10000; break;
25541 case 23: guysbuf[ri->npcdataref].misc24 = value / 10000; break;
25542 case 24: guysbuf[ri->npcdataref].misc25 = value / 10000; break;
25543 case 25: guysbuf[ri->npcdataref].misc26 = value / 10000; break;
25544 case 26: guysbuf[ri->npcdataref].misc27 = value / 10000; break;
25545 case 27: guysbuf[ri->npcdataref].misc28 = value / 10000; break;
25546 case 28: guysbuf[ri->npcdataref].misc29 = value / 10000; break;
25547 case 29: guysbuf[ri->npcdataref].misc30 = value / 10000; break;
25548 case 30: guysbuf[ri->npcdataref].misc31 = value / 10000; break;
25549 case 31: guysbuf[ri->npcdataref].misc32 = value / 10000; break;
25550
25551 default:
25552 {
25553 Z_scripterrlog("Invalid Array Index passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
25554 break;
25555 }
25556 }
25557
25558 }
25559 break;
25560 }
25561
25562 case NPCDATABEHAVIOUR:
25563 {
25564 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
25565 {
25566 break;
25567 }
25568
25569
25570 int32_t index = vbound(ri->d[rINDEX]/10000,0,4);
25571 switch(index){
25572 case 0:
25573 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG1 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG1;
25574 break;
25575 case 1:
25576 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG2 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG2;
25577 break;
25578 case 2:
25579 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG3 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG3;
25580 break;
25581 case 3:
25582 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG4 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG4;
25583 break;
25584 case 4:
25585 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG5 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG5;
25586 break;
25587 case 5:
25588 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG6 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG6;
25589 break;
25590 case 6:
25591 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG7 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG7;
25592 break;
25593 case 7:
25594 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG8 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG8;
25595 break;
25596 case 8:
25597 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG9 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG9;
25598 break;
25599 case 9:
25600 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG10 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG10;
25601 break;
25602 case 10:
25603 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG11 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG11;
25604 break;
25605 case 11:
25606 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG12 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG12;
25607 break;
25608 case 12:
25609 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG13 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG13;
25610 break;
25611 case 13:
25612 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG14 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG14;
25613 break;
25614 case 14:
25615 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG15 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG15;
25616 break;
25617 case 15:
25618 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG16 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG16;
25619 break;
25620
25621
25622 default:
25623 break;
25624 }
25625
25626 break;
25627 }
25628
25629 case NPCDATASHIELD:
25630 {
25631 int32_t indx = ri->d[rINDEX] / 10000;
25632 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
25633 {
25634 Z_scripterrlog("Invalid NPC ID passed to npcdata->Shield[]: %d\n", (ri->npcdataref*10000));
25635 break;
25636 }
25637 else
25638 {
25639 switch(indx)
25640 {
25641 case 0:
25642 {
25643 (ri->d[rINDEX2])? (guysbuf[ri->npcdataref].flags |= inv_front) : (guysbuf[ri->npcdataref].flags &= ~inv_front);
25644 break;
25645 }
25646 case 1:
25647 {
25648 (ri->d[rINDEX2])? (guysbuf[ri->npcdataref].flags |= inv_left) : (guysbuf[ri->npcdataref].flags &= ~inv_left);
25649 break;
25650 }
25651 case 2:
25652 {
25653 (ri->d[rINDEX2])? (guysbuf[ri->npcdataref].flags |= inv_right) : (guysbuf[ri->npcdataref].flags &= ~inv_right);
25654 break;
25655 }
25656 case 3:
25657 {
25658 (ri->d[rINDEX2])? (guysbuf[ri->npcdataref].flags |= inv_back) : (guysbuf[ri->npcdataref].flags &= ~inv_back);
25659 break;
25660 }
25661 case 4:
25662 {
25663 (ri->d[rINDEX2])? (guysbuf[ri->npcdataref].flags |= guy_bkshield) : (guysbuf[ri->npcdataref].flags &= ~guy_bkshield);
25664 break;
25665 }
25666 default:
25667 {
25668 Z_scripterrlog("Invalid Array Index passed to npcdata->Shield[]: %d\n", indx);
25669 break;
25670 }
25671 }
25672 break;
25673 }
25674 }
25675
25676 case NPCDSHADOWSPR:
25677 {
25678 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
25679 {
25680 Z_scripterrlog("Invalid NPC ID passed to npcdata->ShadowSprite: %d\n", (ri->npcdataref*10000));
25681 }
25682 else
25683 {
25684 guysbuf[ri->npcdataref].spr_shadow = vbound(value/10000, 0, 255);
25685 }
25686 break;
25687 }
25688 case NPCDSPAWNSPR:
25689 {
25690 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
25691 {
25692 Z_scripterrlog("Invalid NPC ID passed to npcdata->SpawnSprite: %d\n", (ri->npcdataref*10000));
25693 }
25694 else
25695 {
25696 guysbuf[ri->npcdataref].spr_spawn = vbound(value/10000, 0, 255);
25697 }
25698 break;
25699 }
25700 case NPCDDEATHSPR:
25701 {
25702 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
25703 {
25704 Z_scripterrlog("Invalid NPC ID passed to npcdata->DeathSprite: %d\n", (ri->npcdataref*10000));
25705 }
25706 else
25707 {
25708 guysbuf[ri->npcdataref].spr_death = vbound(value/10000, 0, 255);
25709 }
25710 break;
25711 }
25712
25713
25714 ///----------------------------------------------------------------------------------------------------//
25715 //Dropset Variables
25716
25717 case DROPSETITEMS:
25718 {
25719 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
25720 {
25721 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
25722 break;
25723 }
25724 int32_t indx = ri->d[rINDEX]/10000;
25725 if(indx < 0 || indx > 9)
25726 {
25727 Z_scripterrlog("Invalid index passed to dropdata->Items[]: %d\n", indx);
25728 }
25729 else
25730 {
25731 item_drop_sets[ri->dropsetref].item[indx] = vbound(value / 10000, 0, MAXITEMS-1);
25732 }
25733 break;
25734 }
25735 case DROPSETCHANCES:
25736 {
25737 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
25738 {
25739 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
25740 break;
25741 }
25742 int32_t indx = ri->d[rINDEX]/10000;
25743 if(indx < 0 || indx > 9)
25744 {
25745 Z_scripterrlog("Invalid index passed to dropdata->Chances[]: %d\n", indx);
25746 }
25747 else
25748 {
25749 item_drop_sets[ri->dropsetref].chance[indx+1] = vbound((value / 10000),0,32767); //+1 is because '0' is 'nothing''s chance
25750 }
25751 break;
25752 }
25753 case DROPSETNULLCHANCE:
25754 {
25755 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
25756 {
25757 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
25758 break;
25759 }
25760 item_drop_sets[ri->dropsetref].chance[0] = vbound((value / 10000),0,32767);
25761 break;
25762 }
25763
25764 ///----------------------------------------------------------------------------------------------------//
25765 //Audio Variables
25766
25767 case AUDIOVOLUME:
25768 {
25769 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
25770 break;
25771
25772 int32_t indx = ri->d[rINDEX] / 10000;
25773 //zprint("Volume[index] is: %d", indx);
25774 //int32_t vol = value / 10000;
25775 //zprint("Attempted to change volume to: %d", vol);
25776 switch(indx)
25777 {
25778
25779 case 0: //midi volume
25780 {
25781 if ( !(FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME) )
25782 {
25783 FFCore.usr_midi_volume = FFScript::do_getMIDI_volume();
25784 FFCore.SetFFEngineFlag(FFCORE_SCRIPTED_MIDI_VOLUME,true);
25785 }
25786 FFScript::do_setMIDI_volume(value / 10000);
25787 break;
25788 }
25789 case 1: //digi volume
25790 {
25791 if ( !(FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME) )
25792 {
25793 FFCore.usr_digi_volume = FFScript::do_getDIGI_volume();
25794 FFCore.SetFFEngineFlag(FFCORE_SCRIPTED_DIGI_VOLUME,true);
25795 }
25796 FFScript::do_setDIGI_volume(value / 10000);
25797 break;
25798 }
25799 case 2: //emh music volume
25800 {
25801 if ( !(FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME) )
25802 {
25803 FFCore.usr_music_volume = FFScript::do_getMusic_volume();
25804 FFCore.SetFFEngineFlag(FFCORE_SCRIPTED_MUSIC_VOLUME,true);
25805 }
25806 FFScript::do_setMusic_volume(value / 10000);
25807 break;
25808 }
25809 case 3: //sfx volume
25810 {
25811 if ( !(FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME) )
25812 {
25813 FFCore.usr_sfx_volume = FFScript::do_getSFX_volume();
25814 FFCore.SetFFEngineFlag(FFCORE_SCRIPTED_SFX_VOLUME,true);
25815 }
25816 FFScript::do_setSFX_volume(value / 10000);
25817 break;
25818 }
25819 default:
25820 {
25821 Z_scripterrlog("Attempted to access an invalid index of Audio->Volume[]", indx);
25822 break;
25823 }
25824 }
25825 break;
25826 }
25827
25828 case AUDIOPAN:
25829 {
25830 if ( !(FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE) )
25831 {
25832 FFCore.usr_panstyle = FFScript::do_getSFX_pan();
25833 FFCore.SetFFEngineFlag(FFCORE_SCRIPTED_PANSTYLE,true);
25834 }
25835 FFScript::do_setSFX_pan(value/10000);
25836 break;
25837 }
25838
25839 ///----------------------------------------------------------------------------------------------------//
25840 //Graphics->
25841
25842 case NUMDRAWS:
25843 break;
25844
25845 case MAXDRAWS: break;
25846
25847 ///----------------------------------------------------------------------------------------------------//
25848 //Module->
25849 case MODULEGETSTR:
25850 {
25851 int32_t buf_pointer = ((ri->d[rINDEX])/10000);
25852 int32_t section_pointer = ((ri->d[rINDEX2])/10000);
25853 int32_t element_pointer = (value/10000);
25854
25855 string sectionid;
25856 string elementid;
25857
25858 ArrayH::getString(section_pointer, sectionid);
25859 ArrayH::getString(element_pointer, elementid);
25860
25861 char buffer[256] = {0};
25862
25863
25864 if(!fileexists((char*)moduledata.module_name))
25865 {
25866 Z_scripterrlog("I/O Error: No module definitions found when using Module->GetString()\n");
25867 }
25868 else
25869 {
25870 zc_push_config();
25871 //set config file
25872 zc_config_file(moduledata.module_name);
25873 strcpy(buffer,zc_get_config_basic(sectionid.c_str(), elementid.c_str(), ""));
25874 buffer[255] = '\0';
25875 if(ArrayH::setArray(buf_pointer, buffer) == SH::_Overflow)
25876 Z_scripterrlog("Dest string supplied to 'Module->GetString()' is not large enough\n");
25877 //return config file to zc.cfg
25878 zc_pop_config();
25879 }
25880
25881 break;
25882 }
25883
25884 ///----------------------------------------------------------------------------------------------------//
25885 //Misc./Internal
25886 case SP:
25887 ri->sp = value / 10000;
25888 ri->sp &= MASK_SP;
25889 break;
25890
25891 case PC:
25892 ri->pc = value;
25893 break;
25894
25895 case SWITCHKEY:
25896 ri->switchkey = value;
25897 break;
25898
25899 case SCRIPTRAM:
25900 case GLOBALRAM:
25901 455505918 ArrayH::setElement(ri->d[rINDEX] / 10000, ri->d[rINDEX2] / 10000, value);
25902 455505918 break;
25903
25904 case SCRIPTRAMD:
25905 case GLOBALRAMD:
25906 ArrayH::setElement(ri->d[rINDEX] / 10000, 0, value);
25907 break;
25908
25909 case REFFFC:
25910 503812264 ri->ffcref = value / 10000;
25911 503812264 break;
25912
25913 case REFITEM:
25914 409929 ri->itemref = value;
25915 409929 break;
25916
25917 case REFITEMCLASS:
25918 2162208 ri->idata = value;
25919 2162208 break;
25920
25921 case REFLWPN:
25922 10116373 ri->lwpn = value;
25923 10116373 break;
25924
25925 case REFEWPN:
25926 23554631 ri->ewpn = value;
25927 23554631 break;
25928
25929 case REFNPC:
25930 78146347 ri->guyref = value;
25931 78146347 break;
25932
25933 18561592 case REFMAPDATA: ri->mapsref = value; break;
25934 case REFSCREENDATA: ri->screenref = value; break;
25935 116558 case REFCOMBODATA: ri->combosref = value; break;
25936 64 case REFSPRITEDATA: ri->spritesref = value; break;
25937 265857 case REFBITMAP: ri->bitmapref = value; break;
25938 case REFNPCCLASS: ri->npcdataref = value; break;
25939
25940 806953 case REFDMAPDATA: ri->dmapsref = value; break;
25941 case REFSHOPDATA: ri->shopsref = value; break;
25942 case REFMSGDATA: ri->zmsgref = value; break;
25943 case REFUNTYPED: ri->untypedref = value; break;
25944
25945
25946 case REFDROPS: ri->dropsetref = value; break;
25947 case REFBOTTLETYPE: ri->bottletyperef = value; break;
25948 case REFBOTTLESHOP: ri->bottleshopref = value; break;
25949 142 case REFGENERICDATA: ri->genericdataref = value; break;
25950 case REFPONDS: ri->pondref = value; break;
25951 case REFWARPRINGS: ri->warpringref = value; break;
25952 case REFDOORS: ri->doorsref = value; break;
25953 case REFUICOLOURS: ri->zcoloursref = value; break;
25954 case REFRGB: ri->rgbref = value; break;
25955 case REFPALETTE: ri->paletteref = value; break;
25956 case REFTUNES: ri->tunesref = value; break;
25957 case REFPALCYCLE: ri->palcycleref = value; break;
25958 case REFGAMEDATA: ri->gamedataref = value; break;
25959 case REFCHEATS: ri->cheatsref = value; break;
25960 284 case REFFILE: ri->fileref = value; break;
25961 case REFDIRECTORY: ri->directoryref = value; break;
25962 case REFSTACK: ri->stackref = value; break;
25963 case REFSUBSCREEN: ri->subdataref = value; break;
25964 case REFSUBSCREENPAGE: ri->subpageref = value; break;
25965 case REFSUBSCREENWIDG: ri->subwidgref = value; break;
25966 303330 case REFRNG: ri->rngref = value; break;
25967 case CLASS_THISKEY: ri->thiskey = value; break;
25968 case CLASS_THISKEY2: ri->thiskey2 = value; break;
25969 case REFPALDATA: ri->paldataref = value; break;
25970
25971 //-------------------------------------------------------------------------------------------------
25972
25973 case PALDATACOLOR:
25974 {
25975 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->SetColor()"))
25976 {
25977 int32_t ind = ri->d[rINDEX] / 10000;
25978 if (unsigned(ind) >= PALDATA_NUM_COLORS)
25979 {
25980 Z_scripterrlog("Invalid color index (%d) passed to paldata->SetColor(). Valid indices are 0-255. Aborting.\n", ind);
25981 break;
25982 }
25983 int32_t clri = value;
25984
25985 RGB c = _RGB((clri >> 16) & 0xFF, (clri >> 8) & 0xFF, clri & 0xFF);
25986
25987 if (c.r < 0 || c.g < 0 || c.b < 0)
25988 {
25989 Z_scripterrlog("Invalid rgb (%d) passed to paldata->SetColor().\n", clri);
25990 }
25991 c.r = vbound(c.r, 0, 63);
25992 c.g = vbound(c.g, 0, 63);
25993 c.b = vbound(c.b, 0, 63);
25994
25995 pd->set_color(ind, c);
25996 }
25997 break;
25998 }
25999 case PALDATAR:
26000 FFCore.do_paldata_setrgb(0, value / 10000);
26001 break;
26002 case PALDATAG:
26003 FFCore.do_paldata_setrgb(1, value / 10000);
26004 break;
26005 case PALDATAB:
26006 FFCore.do_paldata_setrgb(2, value / 10000);
26007 break;
26008
26009 //-------------------------------------------------------------------------------------------------
26010
26011 case GENDATARUNNING:
26012 {
26013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "Running"))
26014 {
26015
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(value)
26016 58 scr->launch();
26017 else scr->quit();
26018 58 }
26019 58 break;
26020 }
26021 case GENDATASIZE:
26022 {
26023 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "DataSize"))
26024 {
26025 scr->dataResize(value/10000);
26026 }
26027 break;
26028 }
26029 case GENDATAEXITSTATE:
26030 {
26031 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "ExitState"))
26032 {
26033 size_t indx = ri->d[rINDEX]/10000;
26034 if(indx >= GENSCR_NUMST)
26035 {
26036 Z_scripterrlog("Invalid index passed to genericdata->ReloadState[]: %d\n", indx);
26037 break;
26038 }
26039 SETFLAG(scr->exitState, (1<<indx), value);
26040 }
26041 break;
26042 }
26043 case GENDATARELOADSTATE:
26044 {
26045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "ReloadState"))
26046 {
26047 74 size_t indx = ri->d[rINDEX]/10000;
26048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(indx >= GENSCR_NUMST)
26049 {
26050 Z_scripterrlog("Invalid index passed to genericdata->ReloadState[]: %d\n", indx);
26051 break;
26052 }
26053
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 SETFLAG(scr->reloadState, (1<<indx), value);
26054 74 }
26055 74 break;
26056 }
26057 case GENDATAEVENTSTATE:
26058 {
26059 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "EventListen"))
26060 {
26061 size_t indx = ri->d[rINDEX]/10000;
26062 if(indx >= GENSCR_NUMEVENT)
26063 {
26064 Z_scripterrlog("Invalid index passed to genericdata->EventListen[]: %d\n", indx);
26065 break;
26066 }
26067 SETFLAG(scr->eventstate, (1<<indx), value);
26068 }
26069 break;
26070 }
26071 case GENDATADATA:
26072 {
26073 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "Data[]"))
26074 {
26075 size_t indx = ri->d[rINDEX]/10000;
26076 if(indx >= scr->dataSize())
26077 {
26078 Z_scripterrlog("Invalid index passed to genericdata->Data[]: %d\n", indx);
26079 break;
26080 }
26081 scr->data[indx] = value;
26082 }
26083 break;
26084 }
26085 case GENDATAINITD:
26086 {
26087 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "InitD[]"))
26088 {
26089 size_t indx = ri->d[rINDEX]/10000;
26090 if(indx >= 8)
26091 {
26092 Z_scripterrlog("Invalid index passed to genericdata->InitD[]: %d\n", indx);
26093 break;
26094 }
26095 scr->initd[indx] = value;
26096 }
26097 break;
26098 }
26099
26100 //----------------------------------------------------------------------------------------------------//
26101
26102 case PORTALX:
26103 {
26104 if(portal* p = checkPortal(ri->portalref, "X"))
26105 p->x = zslongToFix(value);
26106 break;
26107 }
26108 case PORTALY:
26109 {
26110 if(portal* p = checkPortal(ri->portalref, "Y"))
26111 p->y = zslongToFix(value);
26112 break;
26113 }
26114 case PORTALDMAP:
26115 {
26116 if(portal* p = checkPortal(ri->portalref, "DMap"))
26117 p->destdmap = vbound(value/10000,-1,MAXDMAPS-1);
26118 break;
26119 }
26120 case PORTALSCREEN:
26121 {
26122 if(portal* p = checkPortal(ri->portalref, "Screen"))
26123 p->destscr = vbound(value/10000,0,255);
26124 break;
26125 }
26126 case PORTALACLK:
26127 {
26128 if(portal* p = checkPortal(ri->portalref, "AClk"))
26129 p->aclk = vbound(value/10000, 0, 9999);
26130 break;
26131 }
26132 case PORTALAFRM:
26133 {
26134 if(portal* p = checkPortal(ri->portalref, "AFrame"))
26135 p->aframe = vbound(value/10000, 0, 9999);
26136 break;
26137 }
26138 case PORTALOTILE:
26139 {
26140 if(portal* p = checkPortal(ri->portalref, "OriginalTile"))
26141 p->o_tile = vbound(value/10000, 0, NEWMAXTILES-1);
26142 break;
26143 }
26144 case PORTALASPD:
26145 {
26146 if(portal* p = checkPortal(ri->portalref, "ASpeed"))
26147 p->aspd = vbound(value/10000, 0, 9999);
26148 break;
26149 }
26150 case PORTALFRAMES:
26151 {
26152 if(portal* p = checkPortal(ri->portalref, "Frames"))
26153 p->frames = vbound(value/10000, 0, 9999);
26154 break;
26155 }
26156 case PORTALSAVED:
26157 {
26158 if(ri->portalref < 0 || value < 0) break;
26159 if(portal* p = checkPortal(ri->portalref, "SavedPortal"))
26160 {
26161 if(!value)
26162 p->saved_data = 0;
26163 else if(savedportal* sp = checkSavedPortal(value, "portal->SavedPortal"))
26164 p->saved_data = sp->getUID();
26165 }
26166 break;
26167 }
26168 case PORTALCLOSEDIS:
26169 {
26170 if(portal* p = checkPortal(ri->portalref, "CloseDisabled"))
26171 p->prox_active = value==0; //Inverted
26172 break;
26173 }
26174 case REFPORTAL:
26175 {
26176 ri->portalref = value;
26177 break;
26178 }
26179 case REFSAVPORTAL:
26180 {
26181 ri->saveportalref = value;
26182 break;
26183 }
26184 case PORTALWARPSFX:
26185 {
26186 if(portal* p = checkPortal(ri->portalref, "WarpSFX"))
26187 p->wsfx = vbound(value/10000,0,255);
26188 break;
26189 }
26190 case PORTALWARPVFX:
26191 {
26192 if(portal* p = checkPortal(ri->portalref, "WarpEffect"))
26193 p->weffect = vbound(value/10000,0,255);
26194 break;
26195 }
26196 case SAVEDPORTALX:
26197 {
26198 if(savedportal* p = checkSavedPortal(ri->saveportalref, "X"))
26199 p->x = value;
26200 break;
26201 }
26202 case SAVEDPORTALY:
26203 {
26204 if(savedportal* p = checkSavedPortal(ri->saveportalref, "Y"))
26205 p->y = value;
26206 break;
26207 }
26208 case SAVEDPORTALSRCDMAP:
26209 {
26210 if(savedportal* p = checkSavedPortal(ri->saveportalref, "SrcDMap"))
26211 p->srcdmap = vbound(value/10000, -1, MAXDMAPS-1);
26212 break;
26213 }
26214 case SAVEDPORTALDESTDMAP:
26215 {
26216 if(savedportal* p = checkSavedPortal(ri->saveportalref, "DestDMap"))
26217 p->destdmap = vbound(value/10000, -1, MAXDMAPS-1);
26218 break;
26219 }
26220 case SAVEDPORTALSRCSCREEN:
26221 {
26222 if(savedportal* p = checkSavedPortal(ri->saveportalref, "SrcScreen"))
26223 p->srcscr = vbound(value/10000,0,255);
26224 break;
26225 }
26226 case SAVEDPORTALDSTSCREEN:
26227 {
26228 if(savedportal* p = checkSavedPortal(ri->saveportalref, "DestScreen"))
26229 p->destscr = vbound(value/10000,0,255);
26230 break;
26231 }
26232 case SAVEDPORTALWARPSFX:
26233 {
26234 if(savedportal* p = checkSavedPortal(ri->saveportalref, "WarpSFX"))
26235 p->sfx = vbound(value/10000,0,255);
26236 break;
26237 }
26238 case SAVEDPORTALWARPVFX:
26239 {
26240 if(savedportal* p = checkSavedPortal(ri->saveportalref, "WarpEffect"))
26241 p->warpfx = vbound(value/10000,0,255);
26242 break;
26243 }
26244 case SAVEDPORTALSPRITE:
26245 {
26246 if(savedportal* p = checkSavedPortal(ri->saveportalref, "Sprite"))
26247 p->spr = vbound(value/10000,0,255);
26248 break;
26249 }
26250 case SAVEDPORTALPORTAL:
26251 {
26252 if(ri->saveportalref < 0 || value < 0) break;
26253 if(savedportal* sp = checkSavedPortal(ri->saveportalref, "Portal"))
26254 {
26255 int32_t id = getPortalFromSaved(sp);
26256 if(id == value) break; //no change
26257 portal* p = checkPortal(value,"savedportal->Portal");
26258 if(p)
26259 {
26260 p->saved_data = sp->getUID();
26261 if(id > 0)
26262 {
26263 portal* p = checkPortal(id,"THIS SHOULD NOT APPEAR");
26264 p->saved_data = 0;
26265 }
26266 }
26267 }
26268 break;
26269 }
26270
26271 case GAMENUMASUB:
26272 {
26273 if(value >= 0)
26274 {
26275 size_t sz = vbound(value/10000, 0, 256);
26276 while(subscreens_active.size() < sz)
26277 {
26278 auto& sub = subscreens_active.emplace_back();
26279 sub.sub_type = sstACTIVE;
26280 }
26281 while(subscreens_active.size() > sz)
26282 subscreens_active.pop_back();
26283 }
26284 break;
26285 }
26286 case GAMENUMPSUB:
26287 {
26288 if(value >= 0)
26289 {
26290 size_t sz = vbound(value/10000, 0, 256);
26291 while(subscreens_passive.size() < sz)
26292 {
26293 auto& sub = subscreens_passive.emplace_back();
26294 sub.sub_type = sstPASSIVE;
26295 }
26296 while(subscreens_passive.size() > sz)
26297 subscreens_passive.pop_back();
26298 }
26299 break;
26300 }
26301 case GAMENUMOSUB:
26302 {
26303 if(value >= 0)
26304 {
26305 size_t sz = vbound(value/10000, 0, 256);
26306 while(subscreens_overlay.size() < sz)
26307 {
26308 auto& sub = subscreens_overlay.emplace_back();
26309 sub.sub_type = sstOVERLAY;
26310 }
26311 while(subscreens_overlay.size() > sz)
26312 subscreens_overlay.pop_back();
26313 }
26314 break;
26315 }
26316 ///----------------------------------------------------------------------------------------------------//
26317
26318 case SUBDATACURPG:
26319 {
26320 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "CurPage"))
26321 if(sub->sub_type == sstACTIVE)
26322 sub->curpage = vbound(value/10000,0,sub->pages.size()-1);
26323 break;
26324 }
26325 case SUBDATANUMPG:
26326 {
26327 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "NumPages"))
26328 if(sub->sub_type == sstACTIVE && value >= 10000)
26329 {
26330 size_t sz = value/10000;
26331 while(sub->pages.size() < sz)
26332 if(!sub->add_page(MAX_SUBSCR_PAGES))
26333 break;
26334 while(sub->pages.size() > sz)
26335 sub->delete_page(sub->pages.size()-1);
26336 }
26337 break;
26338 }
26339 case SUBDATAPAGES: break; //READONLY
26340 case SUBDATATYPE: break; //READONLY
26341 case SUBDATAFLAGS:
26342 {
26343 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "Flags[]"))
26344 {
26345 size_t indx = ri->d[rINDEX]/10000;
26346 size_t sz = 0;
26347 switch(sub->sub_type)
26348 {
26349 case sstACTIVE:
26350 sz = 2;
26351 break;
26352 case sstPASSIVE:
26353 sz = 0;
26354 break;
26355 case sstOVERLAY:
26356 sz = 0;
26357 break;
26358 }
26359 if(indx >= sz)
26360 {
26361 Z_scripterrlog("Bad index '%d' to array "
26362 "'subscreendata->Flags[]' of size '%d'\n", indx, sz);
26363 }
26364 else
26365 SETFLAG(sub->flags,(1<<indx),value);
26366 }
26367 break;
26368 }
26369 ///---- ACTIVE SUBSCREENS ONLY
26370 case SUBDATACURSORPOS:
26371 {
26372 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "CursorPos", sstACTIVE))
26373 {
26374 SubscrPage& pg = sub->cur_page();
26375 //Should this be sanity checked? Or should nulling out
26376 // the cursor by setting it invalid be allowed? -Em
26377 pg.cursor_pos = vbound(value/10000,0,255);
26378 }
26379 break;
26380 }
26381 case SUBDATASCRIPT:
26382 {
26383 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "Script", sstACTIVE))
26384 sub->script = vbound(value/10000,0,NUMSCRIPTSSUBSCREEN-1);
26385 break;
26386 }
26387 case SUBDATAINITD:
26388 {
26389 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "InitD[]", sstACTIVE))
26390 {
26391 size_t indx = ri->d[rINDEX]/10000;
26392 if(indx >= 8)
26393 {
26394 Z_scripterrlog("Bad index '%d' to array "
26395 "'subscreendata->InitD[8]'\n", indx);
26396 }
26397 else
26398 sub->initd[indx] = value;
26399 }
26400 break;
26401 }
26402 case SUBDATABTNLEFT:
26403 {
26404 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "BtnPageLeft[]", sstACTIVE))
26405 {
26406 size_t indx = ri->d[rINDEX]/10000;
26407 if(indx >= 8)
26408 {
26409 Z_scripterrlog("Bad index '%d' to array "
26410 "'subscreendata->BtnPageLeft[8]'\n", indx);
26411 }
26412 else
26413 SETFLAG(sub->btn_left,(1<<indx),value);
26414 }
26415 break;
26416 }
26417 case SUBDATABTNRIGHT:
26418 {
26419 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "BtnPageRight[]", sstACTIVE))
26420 {
26421 size_t indx = ri->d[rINDEX]/10000;
26422 if(indx >= 8)
26423 {
26424 Z_scripterrlog("Bad index '%d' to array "
26425 "'subscreendata->BtnPageRight[8]'\n", indx);
26426 }
26427 else
26428 SETFLAG(sub->btn_right,(1<<indx),value);
26429 }
26430 break;
26431 }
26432 case SUBDATATRANSLEFTTY:
26433 {
26434 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransLeftType", sstACTIVE))
26435 {
26436 auto& trans = sub->trans_left;
26437 trans.type = vbound(value/10000,0,sstrMAX-1);
26438 }
26439 break;
26440 }
26441 case SUBDATATRANSLEFTSFX:
26442 {
26443 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransLeftSFX", sstACTIVE))
26444 {
26445 auto& trans = sub->trans_left;
26446 trans.tr_sfx = vbound(value/10000,0,255);
26447 }
26448 break;
26449 }
26450 case SUBDATATRANSLEFTFLAGS:
26451 {
26452 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransLeftFlags[]", sstACTIVE))
26453 {
26454 auto& trans = sub->trans_left;
26455 size_t indx = ri->d[rINDEX]/10000;
26456 if(indx >= SUBSCR_TRANS_NUMFLAGS)
26457 {
26458 Z_scripterrlog("Bad index '%d' to array "
26459 "'subscreendata->TransLeftFlags[%d]'\n", indx, SUBSCR_TRANS_NUMFLAGS);
26460 }
26461 else
26462 SETFLAG(trans.flags,(1<<indx),value);
26463 }
26464 break;
26465 }
26466 case SUBDATATRANSLEFTARGS:
26467 {
26468 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransLeftArgs[]", sstACTIVE))
26469 {
26470 auto& trans = sub->trans_left;
26471 size_t indx = ri->d[rINDEX]/10000;
26472 if(indx >= SUBSCR_TRANSITION_MAXARG)
26473 {
26474 Z_scripterrlog("Bad index '%d' to array "
26475 "'subscreendata->TransLeftArgs[%d]'\n", indx, SUBSCR_TRANSITION_MAXARG);
26476 }
26477 else
26478 trans.arg[indx] = value/SubscrTransition::argScale(trans.type,indx);
26479 }
26480 break;
26481 }
26482 case SUBDATATRANSRIGHTTY:
26483 {
26484 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransRightType", sstACTIVE))
26485 {
26486 auto& trans = sub->trans_right;
26487 trans.type = vbound(value/10000,0,sstrMAX-1);
26488 }
26489 break;
26490 }
26491 case SUBDATATRANSRIGHTSFX:
26492 {
26493 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransRightSFX", sstACTIVE))
26494 {
26495 auto& trans = sub->trans_right;
26496 trans.tr_sfx = vbound(value/10000,0,255);
26497 }
26498 break;
26499 }
26500 case SUBDATATRANSRIGHTFLAGS:
26501 {
26502 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransRightFlags[]", sstACTIVE))
26503 {
26504 auto& trans = sub->trans_right;
26505 size_t indx = ri->d[rINDEX]/10000;
26506 if(indx >= SUBSCR_TRANS_NUMFLAGS)
26507 {
26508 Z_scripterrlog("Bad index '%d' to array "
26509 "'subscreendata->TransRightFlags[%d]'\n", indx, SUBSCR_TRANS_NUMFLAGS);
26510 }
26511 else
26512 SETFLAG(trans.flags,(1<<indx),value);
26513 }
26514 break;
26515 }
26516 case SUBDATATRANSRIGHTARGS:
26517 {
26518 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransRightArgs[]", sstACTIVE))
26519 {
26520 auto& trans = sub->trans_right;
26521 size_t indx = ri->d[rINDEX]/10000;
26522 if(indx >= SUBSCR_TRANSITION_MAXARG)
26523 {
26524 Z_scripterrlog("Bad index '%d' to array "
26525 "'subscreendata->TransRightArgs[%d]'\n", indx, SUBSCR_TRANSITION_MAXARG);
26526 }
26527 else
26528 trans.arg[indx] = value/SubscrTransition::argScale(trans.type,indx);
26529 }
26530 break;
26531 }
26532 case SUBDATASELECTORDSTX:
26533 {
26534 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestX", sstACTIVE))
26535 sub->selector_setting.x = vbound(value/10000,-32768,32767);
26536 break;
26537 }
26538 case SUBDATASELECTORDSTY:
26539 {
26540 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestY", sstACTIVE))
26541 sub->selector_setting.y = vbound(value/10000,-32768,32767);
26542 break;
26543 }
26544 case SUBDATASELECTORDSTW:
26545 {
26546 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestW", sstACTIVE))
26547 sub->selector_setting.w = vbound(value/10000,-32768,32767);
26548 break;
26549 }
26550 case SUBDATASELECTORDSTH:
26551 {
26552 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestH", sstACTIVE))
26553 sub->selector_setting.h = vbound(value/10000,-32768,32767);
26554 break;
26555 }
26556 case SUBDATASELECTORWID:
26557 {
26558 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestWid", sstACTIVE))
26559 {
26560 size_t indx = ri->d[rINDEX]/10000;
26561 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
26562 {
26563 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
26564 "SelectorDestWid[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
26565 }
26566 else
26567 sub->selector_setting.tileinfo[indx].sw = vbound(value/10000,0,65535);
26568 }
26569 break;
26570 }
26571 case SUBDATASELECTORHEI:
26572 {
26573 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDestHei", sstACTIVE))
26574 {
26575 size_t indx = ri->d[rINDEX]/10000;
26576 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
26577 {
26578 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
26579 "SelectorDestHei[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
26580 }
26581 else
26582 sub->selector_setting.tileinfo[indx].sh = vbound(value/10000,0,65535);
26583 }
26584 break;
26585 }
26586 case SUBDATASELECTORTILE:
26587 {
26588 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorTile", sstACTIVE))
26589 {
26590 size_t indx = ri->d[rINDEX]/10000;
26591 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
26592 {
26593 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
26594 "SelectorTile[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
26595 }
26596 else
26597 sub->selector_setting.tileinfo[indx].tile = vbound(value/10000,0,NEWMAXTILES-1);
26598 }
26599 break;
26600 }
26601 case SUBDATASELECTORCSET:
26602 {
26603 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorCSet", sstACTIVE))
26604 {
26605 size_t indx = ri->d[rINDEX]/10000;
26606 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
26607 {
26608 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
26609 "SelectorCSet[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
26610 }
26611 else
26612 {
26613 byte& cs = sub->selector_setting.tileinfo[indx].cset;
26614 cs = (cs&0xF0)|vbound(value/10000,0,0x0F);
26615 }
26616 }
26617 break;
26618 }
26619 case SUBDATASELECTORFLASHCSET:
26620 {
26621 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorFlashCSet", sstACTIVE))
26622 {
26623 size_t indx = ri->d[rINDEX]/10000;
26624 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
26625 {
26626 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
26627 "SelectorFlashCSet[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
26628 }
26629 else
26630 {
26631 byte& cs = sub->selector_setting.tileinfo[indx].cset;
26632 cs = (cs&0x0F)|(vbound(value/10000,0,0x0F)<<4);
26633 }
26634 }
26635 break;
26636 }
26637 case SUBDATASELECTORFRM:
26638 {
26639 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorFrames", sstACTIVE))
26640 {
26641 size_t indx = ri->d[rINDEX]/10000;
26642 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
26643 {
26644 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
26645 "SelectorFrames[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
26646 }
26647 else
26648 sub->selector_setting.tileinfo[indx].frames = vbound(value/10000,1,255);
26649 }
26650 break;
26651 }
26652 case SUBDATASELECTORASPD:
26653 {
26654 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorASpeed", sstACTIVE))
26655 {
26656 size_t indx = ri->d[rINDEX]/10000;
26657 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
26658 {
26659 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
26660 "SelectorASpeed[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
26661 }
26662 else
26663 sub->selector_setting.tileinfo[indx].speed = vbound(value/10000,1,255);
26664 }
26665 break;
26666 }
26667 case SUBDATASELECTORDELAY:
26668 {
26669 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SelectorDelay", sstACTIVE))
26670 {
26671 size_t indx = ri->d[rINDEX]/10000;
26672 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
26673 {
26674 Z_scripterrlog("Bad index '%d' to array 'subscreendata->"
26675 "SelectorDelay[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
26676 }
26677 else
26678 sub->selector_setting.tileinfo[indx].delay = vbound(value/10000,0,255);
26679 }
26680 break;
26681 }
26682 ///---- CURRENTLY OPEN ACTIVE SUBSCREEN ONLY
26683 case SUBDATATRANSCLK:
26684 {
26685 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransClock", sstACTIVE))
26686 {
26687 if(sub != new_subscreen_active)
26688 Z_scripterrlog("'subscreendata->TransClock' is only"
26689 " valid for the current active subscreen!\n");
26690 else if(subscreen_open)
26691 {
26692 int val = value/10000;
26693 if(val < 0)
26694 subscrpg_clear_animation();
26695 else if(!subscr_pg_animating)
26696 {
26697 SubscrTransition tr = subscr_pg_transition;
26698 tr.tr_sfx = 0;
26699 subscrpg_animate(subscr_pg_from,subscr_pg_to,tr,*new_subscreen_active);
26700 subscr_pg_clk = val;
26701 }
26702 else subscr_pg_clk = val;
26703 }
26704 }
26705 break;
26706 }
26707 case SUBDATATRANSTY:
26708 {
26709 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransType", sstACTIVE))
26710 {
26711 auto& trans = subscr_pg_transition;
26712 if(sub != new_subscreen_active)
26713 Z_scripterrlog("'subscreendata->TransType' is only"
26714 " valid for the current active subscreen!\n");
26715 else if(subscreen_open)
26716 trans.type = vbound(value/10000,0,sstrMAX-1);
26717 }
26718 break;
26719 }
26720 case SUBDATATRANSFLAGS:
26721 {
26722 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransFlags[]", sstACTIVE))
26723 {
26724 auto& trans = subscr_pg_transition;
26725 size_t indx = ri->d[rINDEX]/10000;
26726 if(indx >= SUBSCR_TRANS_NUMFLAGS)
26727 {
26728 Z_scripterrlog("Bad index '%d' to array "
26729 "'subscreendata->TransFlags[%d]'\n", indx, SUBSCR_TRANS_NUMFLAGS);
26730 }
26731 else if(sub != new_subscreen_active)
26732 Z_scripterrlog("'subscreendata->TransType' is only"
26733 " valid for the current active subscreen!\n");
26734 else if(subscreen_open)
26735 SETFLAG(trans.flags,(1<<indx),value);
26736 }
26737 break;
26738 }
26739 case SUBDATATRANSARGS:
26740 {
26741 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransArgs[]", sstACTIVE))
26742 {
26743 auto& trans = subscr_pg_transition;
26744 size_t indx = ri->d[rINDEX]/10000;
26745 if(indx >= SUBSCR_TRANSITION_MAXARG)
26746 {
26747 Z_scripterrlog("Bad index '%d' to array "
26748 "'subscreendata->TransArgs[%d]'\n", indx, SUBSCR_TRANSITION_MAXARG);
26749 }
26750 else if(sub != new_subscreen_active)
26751 Z_scripterrlog("'subscreendata->TransType' is only"
26752 " valid for the current active subscreen!\n");
26753 else if(subscreen_open)
26754 trans.arg[indx] = value/SubscrTransition::argScale(trans.type,indx);
26755 }
26756 break;
26757 }
26758 case SUBDATATRANSFROMPG:
26759 {
26760 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransFromPage", sstACTIVE))
26761 {
26762 if(sub != new_subscreen_active)
26763 Z_scripterrlog("'subscreendata->TransFromPage' is only"
26764 " valid for the current active subscreen!\n");
26765 else if(subscreen_open)
26766 subscr_pg_from = vbound(value/10000,0,sub->pages.size()-1);
26767 }
26768 break;
26769 }
26770 case SUBDATATRANSTOPG:
26771 {
26772 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "TransToPage", sstACTIVE))
26773 {
26774 if(sub != new_subscreen_active)
26775 Z_scripterrlog("'subscreendata->TransToPage' is only"
26776 " valid for the current active subscreen!\n");
26777 else if(subscreen_open)
26778 subscr_pg_to = vbound(value/10000,0,sub->pages.size()-1);
26779 }
26780 break;
26781 }
26782
26783 ///----------------------------------------------------------------------------------------------------//
26784 case SUBPGINDEX: break; //READ-ONLY
26785 case SUBPGNUMWIDG: break; //READ-ONLY
26786 case SUBPGWIDGETS: break; //READ-ONLY
26787 case SUBPGSUBDATA: break; //READ-ONLY
26788 case SUBPGCURSORPOS:
26789 {
26790 if(SubscrPage* pg = checkSubPage(ri->subpageref, "CursorPos"))
26791 pg->cursor_pos = vbound(value/10000,0,255);
26792 break;
26793 }
26794 ///----------------------------------------------------------------------------------------------------//
26795 ///---- ANY WIDGET TYPE
26796 case SUBWIDGTYPE: break; //READ-ONLY
26797 case SUBWIDGINDEX: break; //READ-ONLY
26798 case SUBWIDGPAGE: break; //READ-ONLY
26799 case SUBWIDGDISPITM: break; //READ-ONLY
26800 case SUBWIDGEQPITM: break; //READ-ONLY
26801 case SUBWIDGPOS:
26802 {
26803 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Pos"))
26804 widg->pos = vbound(value/10000,0,255);
26805 break;
26806 }
26807 case SUBWIDGPOSES:
26808 {
26809 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PosDirs"))
26810 {
26811 size_t indx = ri->d[rINDEX]/10000;
26812 if(indx >= 4)
26813 {
26814 Z_scripterrlog("Bad index '%d' to array "
26815 "'subscreenwidget->PosDirs[%d]'\n", indx, 4);
26816 }
26817 else
26818 {
26819 byte val = vbound(value/10000,0,255);
26820 switch(indx)
26821 {
26822 case up:
26823 widg->pos_up = val;
26824 break;
26825 case down:
26826 widg->pos_down = val;
26827 break;
26828 case left:
26829 widg->pos_left = val;
26830 break;
26831 case right:
26832 widg->pos_right = val;
26833 break;
26834 }
26835 }
26836 }
26837 break;
26838 }
26839 case SUBWIDGPOSFLAG:
26840 {
26841 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "VisibleFlags"))
26842 {
26843 size_t indx = ri->d[rINDEX]/10000;
26844 if(indx >= sspNUM)
26845 {
26846 Z_scripterrlog("Bad index '%d' to array "
26847 "'subscreenwidget->VisibleFlags[%d]'\n", indx, sspNUM);
26848 }
26849 else
26850 {
26851 SETFLAG(widg->posflags, 1<<indx, value);
26852 }
26853 }
26854 break;
26855 }
26856 case SUBWIDGX:
26857 {
26858 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "X"))
26859 widg->x = vbound(value/10000,-32768,32767);
26860 break;
26861 }
26862 case SUBWIDGY:
26863 {
26864 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Y"))
26865 widg->y = vbound(value/10000,-32768,32767);
26866 break;
26867 }
26868 case SUBWIDGW:
26869 {
26870 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "W"))
26871 widg->w = vbound(value/10000,0,65535);
26872 break;
26873 }
26874 case SUBWIDGH:
26875 {
26876 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "H"))
26877 widg->h = vbound(value/10000,0,65535);
26878 break;
26879 }
26880 case SUBWIDGGENFLAG:
26881 {
26882 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GenFlags"))
26883 {
26884 size_t indx = ri->d[rINDEX]/10000;
26885 if(indx >= SUBSCRFLAG_GEN_COUNT)
26886 {
26887 Z_scripterrlog("Bad index '%d' to array "
26888 "'subscreenwidget->GenFlags[%d]'\n", indx, SUBSCRFLAG_GEN_COUNT);
26889 }
26890 else
26891 {
26892 SETFLAG(widg->genflags, 1<<indx, value);
26893 }
26894 }
26895 break;
26896 }
26897 case SUBWIDGFLAG:
26898 {
26899 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Flags"))
26900 {
26901 size_t indx = ri->d[rINDEX]/10000;
26902 byte sz = widg->numFlags();
26903 if(indx >= sz)
26904 {
26905 Z_scripterrlog("Bad index '%d' to array "
26906 "'subscreenwidget->Flags[%d]'\n", indx, sz);
26907 }
26908 else
26909 {
26910 SETFLAG(widg->flags, 1<<indx, value);
26911 }
26912 }
26913 break;
26914 }
26915 ///---- ACTIVE SUBSCREENS ONLY
26916 case SUBWIDGSELECTORDSTX:
26917 {
26918 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestX", sstACTIVE))
26919 widg->selector_override.x = vbound(value/10000,-32768,32767);
26920 break;
26921 }
26922 case SUBWIDGSELECTORDSTY:
26923 {
26924 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestY", sstACTIVE))
26925 widg->selector_override.y = vbound(value/10000,-32768,32767);
26926 break;
26927 }
26928 case SUBWIDGSELECTORDSTW:
26929 {
26930 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestW", sstACTIVE))
26931 widg->selector_override.w = vbound(value/10000,-32768,32767);
26932 break;
26933 }
26934 case SUBWIDGSELECTORDSTH:
26935 {
26936 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestH", sstACTIVE))
26937 widg->selector_override.h = vbound(value/10000,-32768,32767);
26938 break;
26939 }
26940 case SUBWIDGSELECTORWID:
26941 {
26942 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestWid", sstACTIVE))
26943 {
26944 size_t indx = ri->d[rINDEX]/10000;
26945 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
26946 {
26947 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
26948 "SelectorDestWid[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
26949 }
26950 else
26951 widg->selector_override.tileinfo[indx].sw = vbound(value/10000,0,65535);
26952 }
26953 break;
26954 }
26955 case SUBWIDGSELECTORHEI:
26956 {
26957 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDestHei", sstACTIVE))
26958 {
26959 size_t indx = ri->d[rINDEX]/10000;
26960 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
26961 {
26962 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
26963 "SelectorDestHei[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
26964 }
26965 else
26966 widg->selector_override.tileinfo[indx].sh = vbound(value/10000,0,65535);
26967 }
26968 break;
26969 }
26970 case SUBWIDGSELECTORTILE:
26971 {
26972 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorTile", sstACTIVE))
26973 {
26974 size_t indx = ri->d[rINDEX]/10000;
26975 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
26976 {
26977 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
26978 "SelectorTile[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
26979 }
26980 else
26981 widg->selector_override.tileinfo[indx].tile = vbound(value/10000,0,NEWMAXTILES-1);
26982 }
26983 break;
26984 }
26985 case SUBWIDGSELECTORCSET:
26986 {
26987 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorCSet", sstACTIVE))
26988 {
26989 size_t indx = ri->d[rINDEX]/10000;
26990 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
26991 {
26992 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
26993 "SelectorCSet[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
26994 }
26995 else
26996 {
26997 byte& cs = widg->selector_override.tileinfo[indx].cset;
26998 cs = (cs&0xF0)|vbound(value/10000,0,0x0F);
26999 }
27000 }
27001 break;
27002 }
27003 case SUBWIDGSELECTORFLASHCSET:
27004 {
27005 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorFlashCSet", sstACTIVE))
27006 {
27007 size_t indx = ri->d[rINDEX]/10000;
27008 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
27009 {
27010 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
27011 "SelectorFlashCSet[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
27012 }
27013 else
27014 {
27015 byte& cs = widg->selector_override.tileinfo[indx].cset;
27016 cs = (cs&0x0F)|(vbound(value/10000,0,0x0F)<<4);
27017 }
27018 }
27019 break;
27020 }
27021 case SUBWIDGSELECTORFRM:
27022 {
27023 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorFrames", sstACTIVE))
27024 {
27025 size_t indx = ri->d[rINDEX]/10000;
27026 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
27027 {
27028 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
27029 "SelectorFrames[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
27030 }
27031 else
27032 widg->selector_override.tileinfo[indx].frames = vbound(value/10000,1,255);
27033 }
27034 break;
27035 }
27036 case SUBWIDGSELECTORASPD:
27037 {
27038 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorASpeed", sstACTIVE))
27039 {
27040 size_t indx = ri->d[rINDEX]/10000;
27041 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
27042 {
27043 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
27044 "SelectorASpeed[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
27045 }
27046 else
27047 widg->selector_override.tileinfo[indx].speed = vbound(value/10000,1,255);
27048 }
27049 break;
27050 }
27051 case SUBWIDGSELECTORDELAY:
27052 {
27053 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SelectorDelay", sstACTIVE))
27054 {
27055 size_t indx = ri->d[rINDEX]/10000;
27056 if(indx >= SUBSCR_SELECTOR_NUMTILEINFO)
27057 {
27058 Z_scripterrlog("Bad index '%d' to array 'subscreenwidget->"
27059 "SelectorDelay[%d]'\n", indx, SUBSCR_SELECTOR_NUMTILEINFO);
27060 }
27061 else
27062 widg->selector_override.tileinfo[indx].delay = vbound(value/10000,0,255);
27063 }
27064 break;
27065 }
27066
27067 case SUBWIDGPRESSSCRIPT:
27068 {
27069 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PressScript", sstACTIVE))
27070 widg->generic_script = vbound(value/10000,0,NUMSCRIPTSGENERIC-1);
27071 break;
27072 }
27073 case SUBWIDGPRESSINITD:
27074 {
27075 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PressInitD[]", sstACTIVE))
27076 {
27077 size_t indx = ri->d[rINDEX]/10000;
27078 if(indx >= 8)
27079 {
27080 Z_scripterrlog("Bad index '%d' to array "
27081 "'subscreenwidget->PressInitD[8]'\n", indx);
27082 }
27083 else
27084 widg->generic_initd[indx] = value;
27085 }
27086 break;
27087 }
27088 case SUBWIDGBTNPRESS:
27089 {
27090 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "BtnPressScript[]", sstACTIVE))
27091 {
27092 size_t indx = ri->d[rINDEX]/10000;
27093 if(indx >= 8)
27094 {
27095 Z_scripterrlog("Bad index '%d' to array "
27096 "'subscreenwidget->BtnPressScript[8]'\n", indx);
27097 }
27098 else
27099 SETFLAG(widg->gen_script_btns,(1<<indx),value);
27100 }
27101 break;
27102 }
27103 case SUBWIDGBTNPG:
27104 {
27105 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "BtnPageChange[]", sstACTIVE))
27106 {
27107 size_t indx = ri->d[rINDEX]/10000;
27108 if(indx >= 8)
27109 {
27110 Z_scripterrlog("Bad index '%d' to array "
27111 "'subscreenwidget->BtnPageChange[8]'\n", indx);
27112 }
27113 else
27114 SETFLAG(widg->pg_btns,(1<<indx),value);
27115 }
27116 break;
27117 }
27118 case SUBWIDGPGMODE:
27119 {
27120 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PageMode", sstACTIVE))
27121 widg->pg_mode = vbound(value/10000,0,PGGOTO_MAX-1);
27122 break;
27123 }
27124 case SUBWIDGPGTARG:
27125 {
27126 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "TargetPage", sstACTIVE))
27127 widg->pg_targ = vbound(value/10000,0,MAX_SUBSCR_PAGES-1);
27128 break;
27129 }
27130
27131 case SUBWIDGTRANSPGTY:
27132 {
27133 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PageTransType", sstACTIVE))
27134 {
27135 auto& trans = widg->pg_trans;
27136 trans.type = vbound(value/10000,0,sstrMAX-1);
27137 }
27138 break;
27139 }
27140 case SUBWIDGTRANSPGSFX:
27141 {
27142 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PageTransSFX", sstACTIVE))
27143 {
27144 auto& trans = widg->pg_trans;
27145 trans.tr_sfx = vbound(value/10000,0,255);
27146 }
27147 break;
27148 }
27149 case SUBWIDGTRANSPGFLAGS:
27150 {
27151 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PageTransFlags[]", sstACTIVE))
27152 {
27153 auto& trans = widg->pg_trans;
27154 size_t indx = ri->d[rINDEX]/10000;
27155 if(indx >= SUBSCR_TRANS_NUMFLAGS)
27156 {
27157 Z_scripterrlog("Bad index '%d' to array "
27158 "'subscreenwidget->PageTransFlags[%d]'\n", indx, SUBSCR_TRANS_NUMFLAGS);
27159 }
27160 else
27161 SETFLAG(trans.flags,(1<<indx),value);
27162 }
27163 break;
27164 }
27165 case SUBWIDGTRANSPGARGS:
27166 {
27167 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PageTransArgs[]", sstACTIVE))
27168 {
27169 auto& trans = widg->pg_trans;
27170 size_t indx = ri->d[rINDEX]/10000;
27171 if(indx >= SUBSCR_TRANSITION_MAXARG)
27172 {
27173 Z_scripterrlog("Bad index '%d' to array "
27174 "'subscreenwidget->PageTransArgs[%d]'\n", indx, SUBSCR_TRANSITION_MAXARG);
27175 }
27176 else
27177 trans.arg[indx] = value/SubscrTransition::argScale(trans.type,indx);
27178 }
27179 break;
27180 }
27181 ///---- VARYING WIDGET TYPES
27182 case SUBWIDGTY_CSET:
27183 {
27184 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "CSet"))
27185 {
27186 auto val = vbound(value/10000,-sscsMAX,15);
27187 size_t indx = ri->d[rINDEX]/10000;
27188 size_t sz = 0;
27189 byte ty = widg->getType();
27190 switch(ty)
27191 {
27192 case widgFRAME:
27193 case widgMCGUFF:
27194 case widgTILEBLOCK:
27195 case widgMINITILE:
27196 sz = 1;
27197 break;
27198 case widgLGAUGE:
27199 case widgMGAUGE:
27200 case widgMISCGAUGE:
27201 sz = 4;
27202 break;
27203 default:
27204 sz = 0;
27205 bad_subwidg_type("CSet[]", false, ty);
27206 break;
27207 }
27208 if(!sz) break;
27209 if(indx >= sz)
27210 {
27211 Z_scripterrlog("Bad index '%d' to array "
27212 "'subscreenwidget->CSet[%d]'\n", indx, sz);
27213 break;
27214 }
27215 switch(ty)
27216 {
27217 case widgFRAME:
27218 ((SW_2x2Frame*)widg)->cs.set_int_cset(val);
27219 break;
27220 case widgMCGUFF:
27221 ((SW_McGuffin*)widg)->cs.set_int_cset(val);
27222 break;
27223 case widgTILEBLOCK:
27224 ((SW_TileBlock*)widg)->cs.set_int_cset(val);
27225 break;
27226 case widgMINITILE:
27227 ((SW_MiniTile*)widg)->cs.set_int_cset(val);
27228 break;
27229 case widgLGAUGE:
27230 case widgMGAUGE:
27231 case widgMISCGAUGE:
27232 val = vbound(value/10000,0,15);
27233 ((SW_GaugePiece*)widg)->mts[indx].cset = val;
27234 break;
27235 }
27236 }
27237 break;
27238 }
27239 case SUBWIDGTY_TILE:
27240 {
27241 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Tile[]"))
27242 {
27243 auto val = vbound(value/10000,0,NEWMAXTILES-1);
27244 size_t indx = ri->d[rINDEX]/10000;
27245 size_t sz = 0;
27246 byte ty = widg->getType();
27247 switch(ty)
27248 {
27249 case widgFRAME:
27250 case widgMCGUFF:
27251 case widgTILEBLOCK:
27252 case widgMINITILE:
27253 sz = 1;
27254 break;
27255 case widgLGAUGE:
27256 case widgMGAUGE:
27257 case widgMISCGAUGE:
27258 sz = 4;
27259 break;
27260 default:
27261 sz = 0;
27262 bad_subwidg_type("Tile[]", false, ty);
27263 break;
27264 }
27265 if(!sz) break;
27266 if(indx >= sz)
27267 {
27268 Z_scripterrlog("Bad index '%d' to array "
27269 "'subscreenwidget->Tile[%d]'\n", indx, sz);
27270 break;
27271 }
27272 switch(ty)
27273 {
27274 case widgFRAME:
27275 ((SW_2x2Frame*)widg)->tile = val;
27276 break;
27277 case widgMCGUFF:
27278 ((SW_McGuffin*)widg)->tile = val;
27279 break;
27280 case widgTILEBLOCK:
27281 ((SW_TileBlock*)widg)->tile = val;
27282 break;
27283 case widgMINITILE:
27284 val = vbound(value/10000,-ssmstMAX,NEWMAXTILES-1);
27285 ((SW_MiniTile*)widg)->set_int_tile(val);
27286 break;
27287 case widgLGAUGE:
27288 case widgMGAUGE:
27289 case widgMISCGAUGE:
27290 ((SW_GaugePiece*)widg)->mts[indx].setTile(val);
27291 break;
27292 }
27293 }
27294 break;
27295 }
27296 case SUBWIDGTY_FONT:
27297 {
27298 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Font"))
27299 {
27300 auto val = vbound(value/10000,0,font_max-1);
27301 auto ty = widg->getType();
27302 switch(ty)
27303 {
27304 case widgTEXT:
27305 ((SW_Text*)widg)->fontid = val;
27306 break;
27307 case widgTEXTBOX:
27308 ((SW_TextBox*)widg)->fontid = val;
27309 break;
27310 case widgSELECTEDTEXT:
27311 ((SW_SelectedText*)widg)->fontid = val;
27312 break;
27313 case widgTIME:
27314 ((SW_Time*)widg)->fontid = val;
27315 break;
27316 case widgCOUNTER:
27317 ((SW_Counter*)widg)->fontid = val;
27318 break;
27319 case widgBTNCOUNTER:
27320 ((SW_BtnCounter*)widg)->fontid = val;
27321 break;
27322 case widgOLDCTR:
27323 ((SW_Counters*)widg)->fontid = val;
27324 break;
27325 case widgMMAPTITLE:
27326 ((SW_MMapTitle*)widg)->fontid = val;
27327 break;
27328 default:
27329 bad_subwidg_type("Font", false, ty);
27330 break;
27331 }
27332 }
27333 break;
27334 }
27335 case SUBWIDGTY_ALIGN:
27336 {
27337 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Align"))
27338 {
27339 auto val = vbound(value/10000,0,sstaMAX-1);
27340 auto ty = widg->getType();
27341 switch(ty)
27342 {
27343 case widgTEXT:
27344 ((SW_Text*)widg)->align = val;
27345 break;
27346 case widgTEXTBOX:
27347 ((SW_TextBox*)widg)->align = val;
27348 break;
27349 case widgSELECTEDTEXT:
27350 ((SW_SelectedText*)widg)->align = val;
27351 break;
27352 case widgTIME:
27353 ((SW_Time*)widg)->align = val;
27354 break;
27355 case widgCOUNTER:
27356 ((SW_Counter*)widg)->align = val;
27357 break;
27358 case widgBTNCOUNTER:
27359 ((SW_BtnCounter*)widg)->align = val;
27360 break;
27361 case widgMMAPTITLE:
27362 ((SW_MMapTitle*)widg)->align = val;
27363 break;
27364 default:
27365 bad_subwidg_type("Align", false, ty);
27366 break;
27367 }
27368 }
27369 break;
27370 }
27371 case SUBWIDGTY_SHADOWTY:
27372 {
27373 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ShadowType"))
27374 {
27375 auto val = vbound(value/10000,0,sstsMAX-1);
27376 auto ty = widg->getType();
27377 switch(ty)
27378 {
27379 case widgTEXT:
27380 ((SW_Text*)widg)->shadtype = val;
27381 break;
27382 case widgTEXTBOX:
27383 ((SW_TextBox*)widg)->shadtype = val;
27384 break;
27385 case widgSELECTEDTEXT:
27386 ((SW_SelectedText*)widg)->shadtype = val;
27387 break;
27388 case widgTIME:
27389 ((SW_Time*)widg)->shadtype = val;
27390 break;
27391 case widgCOUNTER:
27392 ((SW_Counter*)widg)->shadtype = val;
27393 break;
27394 case widgBTNCOUNTER:
27395 ((SW_BtnCounter*)widg)->shadtype = val;
27396 break;
27397 case widgOLDCTR:
27398 ((SW_Counters*)widg)->shadtype = val;
27399 break;
27400 case widgMMAPTITLE:
27401 ((SW_MMapTitle*)widg)->shadtype = val;
27402 break;
27403 default:
27404 bad_subwidg_type("ShadowType", false, ty);
27405 break;
27406 }
27407 }
27408 break;
27409 }
27410 case SUBWIDGTY_COLOR_TXT:
27411 {
27412 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorText"))
27413 {
27414 auto val = vbound(value/10000,-ssctMAX-NUM_SYS_COLORS,255);
27415 auto ty = widg->getType();
27416 switch(ty)
27417 {
27418 case widgTEXT:
27419 ((SW_Text*)widg)->c_text.set_int_color(val);
27420 break;
27421 case widgTEXTBOX:
27422 ((SW_TextBox*)widg)->c_text.set_int_color(val);
27423 break;
27424 case widgSELECTEDTEXT:
27425 ((SW_SelectedText*)widg)->c_text.set_int_color(val);
27426 break;
27427 case widgTIME:
27428 ((SW_Time*)widg)->c_text.set_int_color(val);
27429 break;
27430 case widgCOUNTER:
27431 ((SW_Counter*)widg)->c_text.set_int_color(val);
27432 break;
27433 case widgBTNCOUNTER:
27434 ((SW_BtnCounter*)widg)->c_text.set_int_color(val);
27435 break;
27436 case widgOLDCTR:
27437 ((SW_Counters*)widg)->c_text.set_int_color(val);
27438 break;
27439 case widgMMAPTITLE:
27440 ((SW_MMapTitle*)widg)->c_text.set_int_color(val);
27441 break;
27442 case widgMCGUFF_FRAME:
27443 ((SW_TriFrame*)widg)->c_number.set_int_color(val);
27444 break;
27445 default:
27446 bad_subwidg_type("ColorText", false, ty);
27447 break;
27448 }
27449 }
27450 break;
27451 }
27452 case SUBWIDGTY_COLOR_SHD:
27453 {
27454 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorShadow"))
27455 {
27456 auto val = vbound(value/10000,-ssctMAX-NUM_SYS_COLORS,255);
27457 auto ty = widg->getType();
27458 switch(ty)
27459 {
27460 case widgTEXT:
27461 ((SW_Text*)widg)->c_shadow.set_int_color(val);
27462 break;
27463 case widgTEXTBOX:
27464 ((SW_TextBox*)widg)->c_shadow.set_int_color(val);
27465 break;
27466 case widgSELECTEDTEXT:
27467 ((SW_SelectedText*)widg)->c_shadow.set_int_color(val);
27468 break;
27469 case widgTIME:
27470 ((SW_Time*)widg)->c_shadow.set_int_color(val);
27471 break;
27472 case widgCOUNTER:
27473 ((SW_Counter*)widg)->c_shadow.set_int_color(val);
27474 break;
27475 case widgBTNCOUNTER:
27476 ((SW_BtnCounter*)widg)->c_shadow.set_int_color(val);
27477 break;
27478 case widgOLDCTR:
27479 ((SW_Counters*)widg)->c_shadow.set_int_color(val);
27480 break;
27481 case widgMMAPTITLE:
27482 ((SW_MMapTitle*)widg)->c_shadow.set_int_color(val);
27483 break;
27484 default:
27485 bad_subwidg_type("ColorShadow", false, ty);
27486 break;
27487 }
27488 }
27489 break;
27490 }
27491 case SUBWIDGTY_COLOR_BG:
27492 {
27493 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorBG"))
27494 {
27495 auto val = vbound(value/10000,-ssctMAX-NUM_SYS_COLORS,255);
27496 auto ty = widg->getType();
27497 switch(ty)
27498 {
27499 case widgTEXT:
27500 ((SW_Text*)widg)->c_bg.set_int_color(val);
27501 break;
27502 case widgTEXTBOX:
27503 ((SW_TextBox*)widg)->c_bg.set_int_color(val);;
27504 break;
27505 case widgSELECTEDTEXT:
27506 ((SW_SelectedText*)widg)->c_bg.set_int_color(val);;
27507 break;
27508 case widgTIME:
27509 ((SW_Time*)widg)->c_bg.set_int_color(val);
27510 break;
27511 case widgCOUNTER:
27512 ((SW_Counter*)widg)->c_bg.set_int_color(val);
27513 break;
27514 case widgBTNCOUNTER:
27515 ((SW_BtnCounter*)widg)->c_bg.set_int_color(val);
27516 break;
27517 case widgOLDCTR:
27518 ((SW_Counters*)widg)->c_bg.set_int_color(val);
27519 break;
27520 case widgMMAPTITLE:
27521 ((SW_MMapTitle*)widg)->c_bg.set_int_color(val);
27522 break;
27523 case widgBGCOLOR:
27524 ((SW_Clear*)widg)->c_bg.set_int_color(val);
27525 break;
27526 default:
27527 bad_subwidg_type("ColorBG", false, ty);
27528 break;
27529 }
27530 }
27531 break;
27532 }
27533
27534 case SUBWIDGTY_COLOR_OLINE:
27535 {
27536 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorOutline"))
27537 {
27538 auto val = vbound(value/10000,-ssctMAX-NUM_SYS_COLORS,255);
27539 auto ty = widg->getType();
27540 switch(ty)
27541 {
27542 case widgLINE:
27543 ((SW_Line*)widg)->c_line.set_int_color(val);
27544 break;
27545 case widgRECT:
27546 ((SW_Rect*)widg)->c_outline.set_int_color(val);
27547 break;
27548 case widgMCGUFF_FRAME:
27549 ((SW_TriFrame*)widg)->c_outline.set_int_color(val);
27550 break;
27551 default:
27552 bad_subwidg_type("ColorOutline", false, ty);
27553 break;
27554 }
27555 }
27556 break;
27557 }
27558
27559 case SUBWIDGTY_COLOR_FILL:
27560 {
27561 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorFill"))
27562 {
27563 auto val = vbound(value/10000,-ssctMAX-NUM_SYS_COLORS,255);
27564 auto ty = widg->getType();
27565 switch(ty)
27566 {
27567 case widgRECT:
27568 ((SW_Rect*)widg)->c_fill.set_int_color(val);
27569 break;
27570 default:
27571 bad_subwidg_type("ColorFill", false, ty);
27572 break;
27573 }
27574 }
27575 break;
27576 }
27577 case SUBWIDGTY_BUTTON:
27578 {
27579 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Button"))
27580 {
27581 auto val = vbound(value/10000,0,3);
27582 auto ty = widg->getType();
27583 switch(ty)
27584 {
27585 case widgBTNITM:
27586 ((SW_ButtonItem*)widg)->btn = val;
27587 break;
27588 case widgBTNCOUNTER:
27589 ((SW_BtnCounter*)widg)->btn = val;
27590 break;
27591 default:
27592 bad_subwidg_type("Button", false, ty);
27593 break;
27594 }
27595 }
27596 break;
27597 }
27598 case SUBWIDGTY_COUNTERS:
27599 {
27600 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Counter[]"))
27601 {
27602 auto val = vbound(value/10000,sscMIN+1,MAX_COUNTERS-1);
27603 size_t indx = ri->d[rINDEX]/10000;
27604 size_t sz = 0;
27605 byte ty = widg->getType();
27606 switch(ty)
27607 {
27608 case widgCOUNTER:
27609 sz = 3;
27610 break;
27611 case widgMISCGAUGE:
27612 sz = 1;
27613 break;
27614 default:
27615 sz = 0;
27616 bad_subwidg_type("Counter[]", false, ty);
27617 break;
27618 }
27619 if(!sz) break;
27620 if(indx >= sz)
27621 {
27622 Z_scripterrlog("Bad index '%d' to array "
27623 "'subscreenwidget->Counter[%d]'\n", indx, sz);
27624 break;
27625 }
27626 switch(ty)
27627 {
27628 case widgCOUNTER:
27629 ((SW_Counter*)widg)->ctrs[indx] = val;
27630 break;
27631 case widgMISCGAUGE:
27632 ((SW_MiscGaugePiece*)widg)->counter = val;
27633 break;
27634 }
27635 }
27636 break;
27637 }
27638 case SUBWIDGTY_MINDIG:
27639 {
27640 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "MinDigits"))
27641 {
27642 auto val = vbound(value/10000,0,5);
27643 auto ty = widg->getType();
27644 switch(ty)
27645 {
27646 case widgCOUNTER:
27647 ((SW_Counter*)widg)->mindigits = val;
27648 break;
27649 case widgBTNCOUNTER:
27650 ((SW_BtnCounter*)widg)->mindigits = val;
27651 break;
27652 case widgOLDCTR:
27653 ((SW_Counters*)widg)->digits = val;
27654 break;
27655 default:
27656 bad_subwidg_type("MinDigits", false, ty);
27657 break;
27658 }
27659 }
27660 break;
27661 }
27662 case SUBWIDGTY_MAXDIG:
27663 {
27664 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "MaxDigits"))
27665 {
27666 auto val = vbound(value/10000,0,5);
27667 auto ty = widg->getType();
27668 switch(ty)
27669 {
27670 case widgCOUNTER:
27671 ((SW_Counter*)widg)->maxdigits = val;
27672 break;
27673 case widgBTNCOUNTER:
27674 ((SW_BtnCounter*)widg)->maxdigits = val;
27675 break;
27676 default:
27677 bad_subwidg_type("MaxDigits", false, ty);
27678 break;
27679 }
27680 }
27681 break;
27682 }
27683 case SUBWIDGTY_INFITM:
27684 {
27685 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "InfiniteItem"))
27686 {
27687 auto val = vbound(value/10000,-1,MAXITEMS-1);
27688 auto ty = widg->getType();
27689 switch(ty)
27690 {
27691 case widgCOUNTER:
27692 ((SW_Counter*)widg)->infitm = val;
27693 break;
27694 case widgOLDCTR:
27695 ((SW_Counters*)widg)->infitm = val;
27696 break;
27697 case widgLGAUGE:
27698 case widgMGAUGE:
27699 case widgMISCGAUGE:
27700 ((SW_GaugePiece*)widg)->inf_item = val;
27701 break;
27702 default:
27703 bad_subwidg_type("InfiniteItem", false, ty);
27704 break;
27705 }
27706 }
27707 break;
27708 }
27709 case SUBWIDGTY_INFCHAR:
27710 {
27711 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "InfiniteChar"))
27712 {
27713 char val = vbound(value/10000,0,255);
27714 auto ty = widg->getType();
27715 switch(ty)
27716 {
27717 case widgCOUNTER:
27718 ((SW_Counter*)widg)->infchar = val;
27719 break;
27720 case widgBTNCOUNTER:
27721 ((SW_BtnCounter*)widg)->infchar = val;
27722 break;
27723 case widgOLDCTR:
27724 ((SW_Counters*)widg)->infchar = val;
27725 break;
27726 default:
27727 bad_subwidg_type("InfiniteChar", false, ty);
27728 break;
27729 }
27730 }
27731 break;
27732 }
27733 case SUBWIDGTY_COSTIND:
27734 {
27735 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "CostIndex"))
27736 {
27737 auto val = vbound(value/10000,0,1);
27738 auto ty = widg->getType();
27739 switch(ty)
27740 {
27741 case widgBTNCOUNTER:
27742 ((SW_BtnCounter*)widg)->costind = val;
27743 break;
27744 default:
27745 bad_subwidg_type("CostIndex", false, ty);
27746 break;
27747 }
27748 }
27749 break;
27750 }
27751 case SUBWIDGTY_COLOR_PLAYER:
27752 {
27753 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorPlayer"))
27754 {
27755 auto val = vbound(value/10000,-ssctMAX-NUM_SYS_COLORS,255);
27756 auto ty = widg->getType();
27757 switch(ty)
27758 {
27759 case widgMMAP:
27760 ((SW_MMap*)widg)->c_plr.set_int_color(val);
27761 break;
27762 case widgLMAP:
27763 ((SW_LMap*)widg)->c_plr.set_int_color(val);
27764 break;
27765 default:
27766 bad_subwidg_type("ColorPlayer", false, ty);
27767 break;
27768 }
27769 }
27770 break;
27771 }
27772 case SUBWIDGTY_COLOR_CMPBLNK:
27773 {
27774 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorCompassBlink"))
27775 {
27776 auto val = vbound(value/10000,-ssctMAX-NUM_SYS_COLORS,255);
27777 auto ty = widg->getType();
27778 switch(ty)
27779 {
27780 case widgMMAP:
27781 ((SW_MMap*)widg)->c_cmp_blink.set_int_color(val);
27782 break;
27783 default:
27784 bad_subwidg_type("ColorCompassBlink", false, ty);
27785 break;
27786 }
27787 }
27788 break;
27789 }
27790 case SUBWIDGTY_COLOR_CMPOFF:
27791 {
27792 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorCompassOff"))
27793 {
27794 auto val = vbound(value/10000,-ssctMAX-NUM_SYS_COLORS,255);
27795 auto ty = widg->getType();
27796 switch(ty)
27797 {
27798 case widgMMAP:
27799 ((SW_MMap*)widg)->c_cmp_off.set_int_color(val);
27800 break;
27801 default:
27802 bad_subwidg_type("ColorCompassOff", false, ty);
27803 break;
27804 }
27805 }
27806 break;
27807 }
27808 case SUBWIDGTY_COLOR_ROOM:
27809 {
27810 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ColorRoom"))
27811 {
27812 auto val = vbound(value/10000,-ssctMAX-NUM_SYS_COLORS,255);
27813 auto ty = widg->getType();
27814 switch(ty)
27815 {
27816 case widgLMAP:
27817 ((SW_LMap*)widg)->c_room.set_int_color(val);
27818 break;
27819 default:
27820 bad_subwidg_type("ColorRoom", false, ty);
27821 break;
27822 }
27823 }
27824 break;
27825 }
27826 case SUBWIDGTY_ITEMCLASS:
27827 {
27828 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ItemClass"))
27829 {
27830 auto val = vbound(value/10000,0,itype_maxusable-1);
27831 auto ty = widg->getType();
27832 switch(ty)
27833 {
27834 case widgITEMSLOT:
27835 ((SW_ItemSlot*)widg)->iclass = val;
27836 break;
27837 default:
27838 bad_subwidg_type("ItemClass", false, ty);
27839 break;
27840 }
27841 }
27842 break;
27843 }
27844 case SUBWIDGTY_ITEMID:
27845 {
27846 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ItemID"))
27847 {
27848 auto val = vbound(value/10000,-1,MAXITEMS-1);
27849 auto ty = widg->getType();
27850 switch(ty)
27851 {
27852 case widgITEMSLOT:
27853 ((SW_ItemSlot*)widg)->iid = val;
27854 break;
27855 default:
27856 bad_subwidg_type("ItemID", false, ty);
27857 break;
27858 }
27859 }
27860 break;
27861 }
27862 case SUBWIDGTY_FRAMETILE:
27863 {
27864 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "FrameTile"))
27865 {
27866 auto val = vbound(value/10000,0,NEWMAXTILES-1);
27867 auto ty = widg->getType();
27868 switch(ty)
27869 {
27870 case widgMCGUFF_FRAME:
27871 ((SW_TriFrame*)widg)->frame_tile = val;
27872 break;
27873 default:
27874 bad_subwidg_type("FrameTile", false, ty);
27875 break;
27876 }
27877 }
27878 break;
27879 }
27880 case SUBWIDGTY_FRAMECSET:
27881 {
27882 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "FrameCSet"))
27883 {
27884 auto val = vbound(value/10000,0,15);
27885 auto ty = widg->getType();
27886 switch(ty)
27887 {
27888 case widgMCGUFF_FRAME:
27889 ((SW_TriFrame*)widg)->frame_cset = val;
27890 break;
27891 default:
27892 bad_subwidg_type("FrameCSet", false, ty);
27893 break;
27894 }
27895 }
27896 break;
27897 }
27898 case SUBWIDGTY_PIECETILE:
27899 {
27900 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PieceTile"))
27901 {
27902 auto val = vbound(value/10000,0,NEWMAXTILES-1);
27903 auto ty = widg->getType();
27904 switch(ty)
27905 {
27906 case widgMCGUFF_FRAME:
27907 ((SW_TriFrame*)widg)->piece_tile = val;
27908 break;
27909 default:
27910 bad_subwidg_type("PieceTile", false, ty);
27911 break;
27912 }
27913 }
27914 break;
27915 }
27916 case SUBWIDGTY_PIECECSET:
27917 {
27918 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PieceCSet"))
27919 {
27920 auto val = vbound(value/10000,0,15);
27921 auto ty = widg->getType();
27922 switch(ty)
27923 {
27924 case widgMCGUFF_FRAME:
27925 ((SW_TriFrame*)widg)->piece_cset = val;
27926 break;
27927 default:
27928 bad_subwidg_type("PieceCSet", false, ty);
27929 break;
27930 }
27931 }
27932 break;
27933 }
27934 case SUBWIDGTY_FLIP:
27935 {
27936 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Flip"))
27937 {
27938 auto val = vbound(value/10000,0,15);
27939 auto ty = widg->getType();
27940 switch(ty)
27941 {
27942 case widgMCGUFF:
27943 ((SW_McGuffin*)widg)->flip = val;
27944 break;
27945 case widgTILEBLOCK:
27946 ((SW_TileBlock*)widg)->flip = val;
27947 break;
27948 case widgMINITILE:
27949 ((SW_MiniTile*)widg)->flip = val;
27950 break;
27951 default:
27952 bad_subwidg_type("Flip", false, ty);
27953 break;
27954 }
27955 }
27956 break;
27957 }
27958 case SUBWIDGTY_NUMBER:
27959 {
27960 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Number"))
27961 {
27962 auto val = vbound(value/10000,0,255);
27963 auto ty = widg->getType();
27964 switch(ty)
27965 {
27966 case widgMCGUFF:
27967 ((SW_McGuffin*)widg)->number = val;
27968 break;
27969 default:
27970 bad_subwidg_type("Number", false, ty);
27971 break;
27972 }
27973 }
27974 break;
27975 }
27976 case SUBWIDGTY_CORNER:
27977 {
27978 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Corner[]"))
27979 {
27980 auto val = vbound(value/10000,0,3);
27981 size_t indx = ri->d[rINDEX]/10000;
27982 size_t sz = 0;
27983 byte ty = widg->getType();
27984 switch(ty)
27985 {
27986 case widgMINITILE:
27987 sz = 1;
27988 break;
27989 case widgLGAUGE:
27990 case widgMGAUGE:
27991 case widgMISCGAUGE:
27992 sz = 4;
27993 break;
27994 default:
27995 sz = 0;
27996 bad_subwidg_type("Corner[]", false, ty);
27997 break;
27998 }
27999 if(!sz) break;
28000 if(indx >= sz)
28001 {
28002 Z_scripterrlog("Bad index '%d' to array "
28003 "'subscreenwidget->Corner[%d]'\n", indx, sz);
28004 break;
28005 }
28006 switch(ty)
28007 {
28008 case widgMINITILE:
28009 ((SW_MiniTile*)widg)->crn = val;
28010 break;
28011 case widgLGAUGE:
28012 case widgMGAUGE:
28013 case widgMISCGAUGE:
28014 ((SW_GaugePiece*)widg)->mts[indx].setCrn(val);
28015 break;
28016 }
28017 }
28018 break;
28019 }
28020 case SUBWIDGTY_FRAMES:
28021 {
28022 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Frames"))
28023 {
28024 auto val = vbound(value/10000,1,65535);
28025 auto ty = widg->getType();
28026 switch(ty)
28027 {
28028 case widgLGAUGE:
28029 case widgMGAUGE:
28030 case widgMISCGAUGE:
28031 ((SW_GaugePiece*)widg)->frames = val;
28032 break;
28033 default:
28034 bad_subwidg_type("Frames", false, ty);
28035 break;
28036 }
28037 }
28038 break;
28039 }
28040 case SUBWIDGTY_SPEED:
28041 {
28042 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Speed"))
28043 {
28044 auto val = vbound(value/10000,1,65535);
28045 auto ty = widg->getType();
28046 switch(ty)
28047 {
28048 case widgLGAUGE:
28049 case widgMGAUGE:
28050 case widgMISCGAUGE:
28051 ((SW_GaugePiece*)widg)->speed = val;
28052 break;
28053 default:
28054 bad_subwidg_type("Speed", false, ty);
28055 break;
28056 }
28057 }
28058 break;
28059 }
28060 case SUBWIDGTY_DELAY:
28061 {
28062 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Delay"))
28063 {
28064 auto val = vbound(value/10000,0,65535);
28065 auto ty = widg->getType();
28066 switch(ty)
28067 {
28068 case widgLGAUGE:
28069 case widgMGAUGE:
28070 case widgMISCGAUGE:
28071 ((SW_GaugePiece*)widg)->delay = val;
28072 break;
28073 default:
28074 bad_subwidg_type("Delay", false, ty);
28075 break;
28076 }
28077 }
28078 break;
28079 }
28080 case SUBWIDGTY_CONTAINER:
28081 {
28082 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Container"))
28083 {
28084 auto val = vbound(value/10000,0,65535);
28085 auto ty = widg->getType();
28086 switch(ty)
28087 {
28088 case widgLGAUGE:
28089 case widgMGAUGE:
28090 case widgMISCGAUGE:
28091 ((SW_GaugePiece*)widg)->container = val;
28092 break;
28093 default:
28094 bad_subwidg_type("Container", false, ty);
28095 break;
28096 }
28097 }
28098 break;
28099 }
28100 case SUBWIDGTY_GAUGE_WID:
28101 {
28102 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GaugeWid"))
28103 {
28104 auto val = vbound(value/10000,1,32)-1;
28105 auto ty = widg->getType();
28106 switch(ty)
28107 {
28108 case widgLGAUGE:
28109 case widgMGAUGE:
28110 case widgMISCGAUGE:
28111 ((SW_GaugePiece*)widg)->gauge_wid = val;
28112 break;
28113 default:
28114 bad_subwidg_type("GaugeWid", false, ty);
28115 break;
28116 }
28117 }
28118 break;
28119 }
28120 case SUBWIDGTY_GAUGE_HEI:
28121 {
28122 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GaugeHei"))
28123 {
28124 auto val = vbound(value/10000,1,32)-1;
28125 auto ty = widg->getType();
28126 switch(ty)
28127 {
28128 case widgLGAUGE:
28129 case widgMGAUGE:
28130 case widgMISCGAUGE:
28131 ((SW_GaugePiece*)widg)->gauge_hei = val;
28132 break;
28133 default:
28134 bad_subwidg_type("GaugeHei", false, ty);
28135 break;
28136 }
28137 }
28138 break;
28139 }
28140 case SUBWIDGTY_UNITS:
28141 {
28142 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "Units"))
28143 {
28144 auto val = vbound(value/10000,1,256);
28145 auto ty = widg->getType();
28146 switch(ty)
28147 {
28148 case widgLGAUGE:
28149 case widgMGAUGE:
28150 case widgMISCGAUGE:
28151 ((SW_GaugePiece*)widg)->unit_per_frame = val-1;
28152 break;
28153 default:
28154 bad_subwidg_type("Units", false, ty);
28155 break;
28156 }
28157 }
28158 break;
28159 }
28160 case SUBWIDGTY_HSPACE:
28161 {
28162 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "HSpace"))
28163 {
28164 auto val = vbound(value/10000,-128,127);
28165 auto ty = widg->getType();
28166 switch(ty)
28167 {
28168 case widgLGAUGE:
28169 case widgMGAUGE:
28170 case widgMISCGAUGE:
28171 ((SW_GaugePiece*)widg)->hspace = val;
28172 break;
28173 default:
28174 bad_subwidg_type("HSpace", false, ty);
28175 break;
28176 }
28177 }
28178 break;
28179 }
28180 case SUBWIDGTY_VSPACE:
28181 {
28182 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "VSpace"))
28183 {
28184 auto val = vbound(value/10000,-128,127);
28185 auto ty = widg->getType();
28186 switch(ty)
28187 {
28188 case widgLGAUGE:
28189 case widgMGAUGE:
28190 case widgMISCGAUGE:
28191 ((SW_GaugePiece*)widg)->vspace = val;
28192 break;
28193 default:
28194 bad_subwidg_type("VSpace", false, ty);
28195 break;
28196 }
28197 }
28198 break;
28199 }
28200 case SUBWIDGTY_GRIDX:
28201 {
28202 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GridX"))
28203 {
28204 auto val = vbound(value/10000,-32768,32767);
28205 auto ty = widg->getType();
28206 switch(ty)
28207 {
28208 case widgLGAUGE:
28209 case widgMGAUGE:
28210 case widgMISCGAUGE:
28211 ((SW_GaugePiece*)widg)->grid_xoff = val;
28212 break;
28213 default:
28214 bad_subwidg_type("GridX", false, ty);
28215 break;
28216 }
28217 }
28218 break;
28219 }
28220 case SUBWIDGTY_GRIDY:
28221 {
28222 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GridY"))
28223 {
28224 auto val = vbound(value/10000,-32768,32767);
28225 auto ty = widg->getType();
28226 switch(ty)
28227 {
28228 case widgLGAUGE:
28229 case widgMGAUGE:
28230 case widgMISCGAUGE:
28231 ((SW_GaugePiece*)widg)->grid_yoff = val;
28232 break;
28233 default:
28234 bad_subwidg_type("GridY", false, ty);
28235 break;
28236 }
28237 }
28238 break;
28239 }
28240 case SUBWIDGTY_ANIMVAL:
28241 {
28242 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "AnimVal"))
28243 {
28244 auto val = vbound(value/10000,0,65535);
28245 auto ty = widg->getType();
28246 switch(ty)
28247 {
28248 case widgLGAUGE:
28249 case widgMGAUGE:
28250 case widgMISCGAUGE:
28251 ((SW_GaugePiece*)widg)->anim_val = val;
28252 break;
28253 default:
28254 bad_subwidg_type("AnimVal", false, ty);
28255 break;
28256 }
28257 }
28258 break;
28259 }
28260 case SUBWIDGTY_SHOWDRAIN:
28261 {
28262 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "ShowDrain"))
28263 {
28264 auto val = vbound(value/10000,-1,32767);
28265 auto ty = widg->getType();
28266 switch(ty)
28267 {
28268 case widgMGAUGE:
28269 ((SW_MagicGaugePiece*)widg)->showdrain = val;
28270 break;
28271 default:
28272 bad_subwidg_type("ShowDrain", false, ty);
28273 break;
28274 }
28275 }
28276 break;
28277 }
28278 case SUBWIDGTY_PERCONTAINER:
28279 {
28280 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "PerContainer"))
28281 {
28282 auto val = vbound(value/10000,1,65535);
28283 auto ty = widg->getType();
28284 switch(ty)
28285 {
28286 case widgMGAUGE:
28287 ((SW_MiscGaugePiece*)widg)->per_container = val;
28288 break;
28289 default:
28290 bad_subwidg_type("PerContainer", false, ty);
28291 break;
28292 }
28293 }
28294 break;
28295 }
28296 case SUBWIDGTY_TABSIZE:
28297 {
28298 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "TabSize"))
28299 {
28300 auto val = vbound(value/10000,0,255);
28301 auto ty = widg->getType();
28302 switch(ty)
28303 {
28304 case widgTEXTBOX:
28305 ((SW_TextBox*)widg)->tabsize = val;
28306 break;
28307 case widgSELECTEDTEXT:
28308 ((SW_SelectedText*)widg)->tabsize = val;
28309 break;
28310 default:
28311 bad_subwidg_type("TabSize", false, ty);
28312 break;
28313 }
28314 }
28315 break;
28316 }
28317 ///----------------------------------------------------------------------------------------------------//
28318
28319 default:
28320 {
28321
2/4
✓ Branch 0 taken 261989134 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 261989134 times.
261989134 if(arg >= D(0) && arg <= D(7)) ri->d[arg - D(0)] = value;
28322 else if(arg >= A(0) && arg <= A(1)) ri->a[arg - A(0)] = value;
28323 else if(arg >= GD(0) && arg <= GD(MAX_SCRIPT_REGISTERS)) game->global_d[arg-GD(0)] = value;
28324
28325 261989134 break;
28326 }
28327 }
28328 1401361646 } //end set_register
28329
28330 int32_t get_int_arr(const int32_t ptr, int32_t indx)
28331 {
28332 switch(ptr)
28333 {
28334 case INTARR_SCREEN_NPC:
28335 {
28336 if(BC::checkGuyIndex(indx, "Screen->NPCs[]") != SH::_NoError)
28337 return 0;
28338 return guys.spr(indx)->getUID();
28339 }
28340 case INTARR_SCREEN_ITEMSPR:
28341 {
28342 if(BC::checkItemIndex(indx, "Screen->Items[]") != SH::_NoError)
28343 return 0;
28344 return items.spr(indx)->getUID();
28345 }
28346 case INTARR_SCREEN_LWPN:
28347 {
28348 if(BC::checkLWeaponIndex(indx, "Screen->LWeapons[]") != SH::_NoError)
28349 return 0;
28350 return Lwpns.spr(indx)->getUID();
28351 }
28352 case INTARR_SCREEN_EWPN:
28353 {
28354 if(BC::checkEWeaponIndex(indx, "Screen->EWeapons[]") != SH::_NoError)
28355 return 0;
28356 return Ewpns.spr(indx)->getUID();
28357 }
28358 case INTARR_SCREEN_FFC:
28359 {
28360 if(BC::checkFFC(indx, "Screen->FFCs[]") != SH::_NoError)
28361 return 0;
28362 return indx*10000;
28363 }
28364 case INTARR_SCREEN_PORTALS:
28365 {
28366 if(BC::checkBoundsOneIndexed(indx, 0, portals.Count()-1, "Screen->Portals[]") != SH::_NoError)
28367 return 0;
28368 return portals.spr(indx)->getUID();
28369 }
28370 case INTARR_SAVPRTL:
28371 {
28372 if(BC::checkBoundsOneIndexed(indx, 0, game->user_portals.size()-1, "Game->SavedPortals[]") != SH::_NoError)
28373 return 0;
28374 return (indx+1)*10000;
28375 }
28376 default:
28377 {
28378 Z_scripterrlog("Unknown internal array '%d' read from!\n", ptr);
28379 return 0;
28380 }
28381 }
28382 }
28383 void set_int_arr(const int32_t ptr, int32_t indx, int32_t val)
28384 {
28385 switch(ptr)
28386 {
28387 case INTARR_SCREEN_NPC:
28388 Z_scripterrlog("Read-only array 'Screen->NPCs' cannot be written to!\n");
28389 return;
28390 case INTARR_SCREEN_ITEMSPR:
28391 Z_scripterrlog("Read-only array 'Screen->Items' cannot be written to!\n");
28392 return;
28393 case INTARR_SCREEN_LWPN:
28394 Z_scripterrlog("Read-only array 'Screen->LWeapons' cannot be written to!\n");
28395 return;
28396 case INTARR_SCREEN_EWPN:
28397 Z_scripterrlog("Read-only array 'Screen->EWeapons' cannot be written to!\n");
28398 return;
28399 case INTARR_SCREEN_FFC:
28400 Z_scripterrlog("Read-only array 'Screen->FFCs' cannot be written to!\n");
28401 return;
28402 case INTARR_SCREEN_PORTALS:
28403 Z_scripterrlog("Read-only array 'Screen->Portals' cannot be written to!\n");
28404 return;
28405 case INTARR_SAVPRTL:
28406 Z_scripterrlog("Read-only array 'Game->SavedPortals' cannot be written to!\n");
28407 return;
28408
28409 default:
28410 {
28411 Z_scripterrlog("Unknown internal array '%d' written to!\n", ptr);
28412 return;
28413 }
28414 }
28415 }
28416 int32_t sz_int_arr(const int32_t ptr)
28417 {
28418 switch(ptr)
28419 {
28420 case INTARR_SCREEN_NPC:
28421 {
28422 return guys.Count();
28423 }
28424 case INTARR_SCREEN_ITEMSPR:
28425 {
28426 return items.Count();
28427 }
28428 case INTARR_SCREEN_LWPN:
28429 {
28430 return Lwpns.Count();
28431 }
28432 case INTARR_SCREEN_EWPN:
28433 {
28434 return Ewpns.Count();
28435 }
28436 case INTARR_SCREEN_FFC:
28437 {
28438 return MAXFFCS;
28439 }
28440 case INTARR_SCREEN_PORTALS:
28441 {
28442 return portals.Count();
28443 }
28444 case INTARR_SAVPRTL:
28445 {
28446 return game->user_portals.size();
28447 }
28448 default:
28449 {
28450 Z_scripterrlog("Unknown internal array '%d' size read!\n", ptr);
28451 return -1;
28452 }
28453 }
28454 }
28455
28456 ///----------------------------------------------------------------------------------------------------//
28457 // ASM Functions //
28458 ///----------------------------------------------------------------------------------------------------//
28459
28460
28461 ///----------------------------------------------------------------------------------------------------//
28462 //Internal (to ZScript)
28463
28464 void do_set(const bool v, ScriptType whichType, const int32_t whichUID)
28465 {
28466 bool allowed = true;
28467 switch(whichType) //Check for objects attempting to change own script
28468 {
28469 //case ScriptType::Global:
28470
28471 case ScriptType::FFC:
28472 if(sarg1==FFSCRIPT && ri->ffcref==whichUID)
28473 allowed = false;
28474 break;
28475
28476 case ScriptType::Screen:
28477 if(sarg1==SCREENSCRIPT) //Only 1 screen script running at a time, no UID check needed
28478 allowed = false;
28479 break;
28480
28481 //case ScriptType::Player:
28482
28483 case ScriptType::Item:
28484 {
28485 bool collect = ( ( whichUID < 1 ) || (whichUID == COLLECT_SCRIPT_ITEM_ZERO) );
28486 int32_t new_UID = ( collect ) ? (( whichUID != COLLECT_SCRIPT_ITEM_ZERO ) ? (whichUID * -1) : 0) : whichUID;
28487
28488 if(collect)
28489 {
28490 if(sarg1==IDATAPSCRIPT && ri->idata==new_UID)
28491 allowed = false;
28492 }
28493 else if(sarg1==IDATASCRIPT && ri->idata==new_UID)
28494 allowed = false;
28495 break;
28496 }
28497
28498 case ScriptType::Lwpn:
28499 if(sarg1==LWPNSCRIPT && ri->lwpn==whichUID)
28500 allowed = false;
28501 break;
28502
28503 case ScriptType::NPC:
28504 if(sarg1==NPCSCRIPT && ri->guyref==whichUID)
28505 allowed = false;
28506 break;
28507
28508 case ScriptType::Ewpn:
28509 if(sarg1==EWPNSCRIPT && ri->ewpn==whichUID)
28510 allowed = false;
28511 break;
28512
28513 case ScriptType::DMap:
28514 if(sarg1==DMAPSCRIPT && ri->dmapsref==whichUID)
28515 allowed = false;
28516 break;
28517
28518 case ScriptType::ItemSprite:
28519 if(sarg1==ITEMSPRITESCRIPT && ri->itemref==whichUID)
28520 allowed = false;
28521 break;
28522 }
28523 if(!allowed)
28524 {
28525 Z_scripterrlog("Script attempted to change own object's script! This has been ignored.\n");
28526 return;
28527 }
28528 int32_t temp = SH::get_arg(sarg2, v);
28529 set_register(sarg1, temp);
28530 }
28531
28532 void do_push(const bool v)
28533 {
28534 const int32_t value = SH::get_arg(sarg1, v);
28535 --ri->sp;
28536 ri->sp &= MASK_SP;
28537 SH::write_stack(ri->sp, value);
28538 }
28539 59809 void do_push_varg(const bool v)
28540 {
28541 59809 const int32_t value = SH::get_arg(sarg1, v);
28542 59809 zs_vargs.push_back(value);
28543 59809 }
28544
28545 void do_pop()
28546 {
28547 const int32_t value = SH::read_stack(ri->sp);
28548 ++ri->sp;
28549 ri->sp &= MASK_SP;
28550 set_register(sarg1, value);
28551 }
28552
28553 70999 void do_peek()
28554 {
28555 70999 set_register(sarg1, SH::read_stack(ri->sp));
28556 70999 }
28557
28558 void do_peekat(const bool v)
28559 {
28560 auto offs = SH::get_arg(sarg2,v);
28561 set_register(sarg1, SH::read_stack(ri->sp+offs));
28562 }
28563
28564 void do_pops() // Pop past a bunch of stuff at once. Useful for clearing the stack.
28565 {
28566 int32_t num = sarg2;
28567 ri->sp += num;
28568 ri->sp &= MASK_SP;
28569 word read = (ri->sp-1) & MASK_SP;
28570 int32_t value = SH::read_stack(read);
28571 set_register(sarg1, value);
28572 }
28573
28574 void do_loadi()
28575 {
28576 const int32_t stackoffset = get_register(sarg2) / 10000;
28577 const int32_t value = SH::read_stack(stackoffset);
28578 set_register(sarg1, value);
28579 }
28580
28581 void do_storei()
28582 {
28583 const int32_t stackoffset = get_register(sarg2) / 10000;
28584 const int32_t value = get_register(sarg1);
28585 SH::write_stack(stackoffset, value);
28586 }
28587
28588 void do_loadd()
28589 {
28590 const int32_t stackoffset = (sarg2+ri->d[rSFRAME]) / 10000;
28591 const int32_t value = SH::read_stack(stackoffset);
28592 set_register(sarg1, value);
28593 }
28594
28595 void do_stored()
28596 {
28597 const int32_t stackoffset = (sarg2+ri->d[rSFRAME]) / 10000;
28598 const int32_t value = get_register(sarg1);
28599 SH::write_stack(stackoffset, value);
28600 }
28601
28602 void do_enqueue(const bool)
28603 {
28604 }
28605 void do_dequeue(const bool)
28606 {
28607 }
28608
28609 void do_comp(bool v, const bool inv = false)
28610 {
28611 bool v2 = false;
28612 if(inv) zc_swap(v,v2);
28613 int32_t temp = SH::get_arg(sarg2, v);
28614 int32_t temp2 = SH::get_arg(sarg1, v2);
28615
28616 if(temp2 >= temp) ri->scriptflag |= MOREFLAG;
28617 else ri->scriptflag &= ~MOREFLAG;
28618
28619 if(temp2 == temp) ri->scriptflag |= TRUEFLAG;
28620 else ri->scriptflag &= ~TRUEFLAG;
28621 }
28622
28623 void do_internal_strcmp()
28624 {
28625 int32_t arrayptr_a = get_register(sarg1)/10000;
28626 int32_t arrayptr_b = get_register(sarg2)/10000;
28627 string strA;
28628 string strB;
28629 ArrayH::getString(arrayptr_a, strA);
28630 ArrayH::getString(arrayptr_b, strB);
28631 int32_t temp = strcmp(strA.c_str(), strB.c_str());
28632
28633 if(temp >= 0) ri->scriptflag |= MOREFLAG;
28634 else ri->scriptflag &= ~MOREFLAG;
28635
28636 if(temp == 0) ri->scriptflag |= TRUEFLAG;
28637 else ri->scriptflag &= ~TRUEFLAG;
28638 }
28639
28640 void do_internal_stricmp()
28641 {
28642 int32_t arrayptr_a = get_register(sarg1)/10000;
28643 int32_t arrayptr_b = get_register(sarg2)/10000;
28644 string strA;
28645 string strB;
28646 ArrayH::getString(arrayptr_a, strA);
28647 ArrayH::getString(arrayptr_b, strB);
28648 int32_t temp = stricmp(strA.c_str(), strB.c_str());
28649
28650 if(temp >= 0) ri->scriptflag |= MOREFLAG;
28651 else ri->scriptflag &= ~MOREFLAG;
28652
28653 if(temp == 0) ri->scriptflag |= TRUEFLAG;
28654 else ri->scriptflag &= ~TRUEFLAG;
28655 }
28656
28657 void do_resize_array()
28658 {
28659 int32_t size = vbound(get_register(sarg2) / 10000, 0, 214748);
28660 dword ptrval = get_register(sarg1) / 10000;
28661 ArrayManager am(ptrval);
28662 am.resize(size);
28663 }
28664
28665 void do_own_array(dword arrindx, ScriptType scriptType, const int32_t UID)
28666 {
28667 ArrayManager am(arrindx);
28668
28669 if(am.internal())
28670 {
28671 Z_scripterrlog("Cannot 'OwnArray()' an internal array '%d'\n", arrindx);
28672 return;
28673 }
28674 if(arrindx >= NUM_ZSCRIPT_ARRAYS && arrindx < NUM_ZSCRIPT_ARRAYS*2)
28675 {
28676 //ignore global arrays
28677 }
28678 else if(!am.invalid())
28679 {
28680 if(arrindx > 0 && arrindx < NUM_ZSCRIPT_ARRAYS)
28681 {
28682 arrayOwner[arrindx].reown(scriptType, UID);
28683 }
28684 else if(arrindx < 0) //object array
28685 Z_scripterrlog("Cannot 'OwnArray()' an object-based array '%d'\n", arrindx);
28686 }
28687 else Z_scripterrlog("Tried to 'OwnArray()' an invalid array '%d'\n", arrindx);
28688 }
28689 void do_destroy_array()
28690 {
28691 dword arrindx = get_register(sarg1) / 10000;
28692
28693 ArrayManager am(arrindx);
28694
28695 if(am.internal())
28696 {
28697 Z_scripterrlog("Cannot 'DestroyArray()' an internal array '%d'\n", arrindx);
28698 return;
28699 }
28700
28701 if(arrindx >= NUM_ZSCRIPT_ARRAYS && arrindx < NUM_ZSCRIPT_ARRAYS*2)
28702 {
28703 //ignore global arrays
28704 }
28705 else if(!am.invalid())
28706 {
28707 if(arrindx > 0 && arrindx < NUM_ZSCRIPT_ARRAYS)
28708 {
28709 arrayOwner[arrindx].clear();
28710
28711 if(localRAM[arrindx].Valid())
28712 localRAM[arrindx].Clear();
28713
28714 arrayOwner[arrindx].specCleared = true;
28715 }
28716 else if(arrindx < 0) //object array
28717 Z_scripterrlog("Cannot 'DestroyArray()' an object-based array '%d'\n", arrindx);
28718 }
28719 else Z_scripterrlog("Tried to 'DestroyArray()' an invalid array '%d'\n", arrindx);
28720 }
28721 7025292 void do_allocatemem(const bool v, const bool local, ScriptType type, const uint32_t UID)
28722 {
28723 7025292 const int32_t size = SH::get_arg(sarg2, v) / 10000;
28724 dword ptrval;
28725
28726
1/2
✓ Branch 0 taken 7025292 times.
✗ Branch 1 not taken.
7025292 if(size < 0)
28727 {
28728 Z_scripterrlog("Array initialized to invalid size of %d\n", size);
28729 set_register(sarg1, 0); //Pass back NULL
28730 return;
28731 }
28732
28733
2/2
✓ Branch 0 taken 7024960 times.
✓ Branch 1 taken 332 times.
7025292 if(local)
28734 {
28735 //localRAM[0] is used as an invalid container, so 0 can be the NULL pointer in ZScript
28736
2/2
✓ Branch 0 taken 383549975 times.
✓ Branch 1 taken 7024960 times.
390574935 for(ptrval = 1; localRAM[ptrval].Valid(); ptrval++) ;
28737
28738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024960 times.
7024960 if(ptrval >= NUM_ZSCRIPT_ARRAYS)
28739 {
28740 Z_scripterrlog("%d local arrays already in use, no more can be allocated\n", NUM_ZSCRIPT_ARRAYS-1);
28741 ptrval = 0;
28742 }
28743 else
28744 {
28745 7024960 ZScriptArray &a = localRAM[ptrval]; //marginally faster for large arrays if we use a reference
28746
28747 7024960 a.Resize(size);
28748 7024960 a.setValid(true);
28749
28750
2/2
✓ Branch 0 taken 109366809 times.
✓ Branch 1 taken 7024960 times.
116391769 for(dword j = 0; j < (dword)size; j++)
28751 109366809 a[j] = 0; //initialize array
28752
28753 // Keep track of which object created the array so we know which to deallocate
28754 //Z_eventlog("Allocating array %d to script %s, %d\n", ptrval, script_types[type], UID);
28755 7024960 arrayOwner[ptrval].reown(type, UID);
28756 }
28757 7024960 }
28758 else
28759 {
28760 //Globals are only allocated here at first play, otherwise in init_game
28761
2/2
✓ Branch 0 taken 5782 times.
✓ Branch 1 taken 332 times.
6114 for(ptrval = 0; game->globalRAM[ptrval].Valid(); ptrval++) ;
28762
28763
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 if(ptrval >= game->globalRAM.size())
28764 {
28765 al_trace("Invalid pointer value of %u passed to global allocate\n", ptrval);
28766 //this shouldn't happen, unless people are putting ALLOCATEGMEM in their ZASM scripts where they shouldn't be
28767 }
28768
28769 332 ZScriptArray &a = game->globalRAM[ptrval];
28770
28771 332 a.Resize(size);
28772 332 a.setValid(true);
28773
28774
2/2
✓ Branch 0 taken 543751 times.
✓ Branch 1 taken 332 times.
544083 for(dword j = 0; j < (dword)size; j++)
28775 543751 a[j] = 0;
28776
28777 332 ptrval += NUM_ZSCRIPT_ARRAYS; //so each pointer has a unique value
28778 }
28779
28780
28781 7025292 set_register(sarg1, ptrval * 10000);
28782
28783 // If this happens once per frame, it can drown out every other message. -L
28784 /*Z_eventlog("Allocated %s array of size %d, pointer address %ld\n",
28785 local ? "local": "global", size, ptrval);*/
28786 7025292 }
28787
28788 7000433 void do_deallocatemem()
28789 {
28790 7000433 const int32_t ptrval = get_register(sarg1) / 10000;
28791
28792 7000433 FFScript::deallocateZScriptArray(ptrval);
28793 7000433 }
28794
28795 void do_loada(const byte a)
28796 {
28797 if(ri->a[a] == 0)
28798 {
28799 Z_eventlog("Global scripts currently have no A registers\n");
28800 return;
28801 }
28802
28803 int32_t ffcref = (ri->a[a] / 10000) - 1; //FFC 2
28804
28805 if(BC::checkFFC(ffcref, "LOAD%i") != SH::_NoError)
28806 return;
28807
28808 int32_t reg = get_register(sarg2); //Register in FFC 2
28809
28810 if(reg >= D(0) && reg <= D(7))
28811 set_register(sarg1, FFCore.ref(ScriptType::FFC, ffcref).d[reg - D(0)]); //get back the info into *sarg1
28812 else if(reg == A(0) || reg == A(1))
28813 set_register(sarg1, FFCore.ref(ScriptType::FFC, ffcref).a[reg - A(0)]);
28814 else if(reg == SP)
28815 set_register(sarg1, FFCore.ref(ScriptType::FFC, ffcref).sp * 10000);
28816
28817 //Can get everything else using REFFFC
28818 }
28819
28820 void do_seta(const byte a)
28821 {
28822 if(ri->a[a] == 0)
28823 {
28824 Z_eventlog("Global scripts currently have no A registers\n");
28825 return;
28826 }
28827
28828 int32_t ffcref = (ri->a[a] / 10000) - 1; //FFC 2
28829
28830 if(BC::checkFFC(ffcref, "SETA%i") != SH::_NoError)
28831 return;
28832
28833 int32_t reg = get_register(sarg2); //Register in FFC 2
28834
28835 if(reg >= D(0) && reg <= D(7))
28836 FFCore.ref(ScriptType::FFC, ffcref).d[reg - D(0)] = get_register(sarg1); //Set it to *sarg1
28837 else if(reg == A(0) || reg == A(1))
28838 FFCore.ref(ScriptType::FFC, ffcref).a[reg - A(0)] = get_register(sarg1);
28839 else if(reg == SP)
28840 FFCore.ref(ScriptType::FFC, ffcref).sp = get_register(sarg1) / 10000;
28841 }
28842
28843 ///----------------------------------------------------------------------------------------------------//
28844 //Mathematical
28845
28846 void do_add(const bool v)
28847 {
28848 int32_t temp = SH::get_arg(sarg2, v);
28849 int32_t temp2 = get_register(sarg1);
28850
28851 set_register(sarg1, temp2 + temp);
28852 }
28853
28854 void do_sub(bool v, const bool inv = false)
28855 {
28856 bool v2 = false;
28857 if(inv) zc_swap(v,v2);
28858 auto destreg = (inv ? sarg2 : sarg1);
28859 int32_t temp = SH::get_arg(sarg2, v);
28860 int32_t temp2 = SH::get_arg(sarg1, v2);
28861 //zprint2("Subtraction found: '%d - %d' where '%s - %s'\n", temp2, temp, v2 ? "const" : "reg", v ? "const" : "reg");
28862 set_register(destreg, temp2 - temp);
28863 }
28864
28865 void do_mult(const bool v)
28866 {
28867 int64_t temp = SH::get_arg(sarg2, v);
28868 int32_t temp2 = get_register(sarg1);
28869
28870 set_register(sarg1, int32_t((temp * temp2) / 10000));
28871 }
28872
28873 930 void do_div(bool v, const bool inv = false)
28874 {
28875 930 bool v2 = false;
28876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930 times.
930 if(inv) zc_swap(v,v2);
28877
1/2
✓ Branch 0 taken 930 times.
✗ Branch 1 not taken.
930 auto destreg = (inv ? sarg2 : sarg1);
28878 930 int64_t temp = SH::get_arg(sarg2, v);
28879 930 int64_t temp2 = SH::get_arg(sarg1, v2);
28880
28881
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 918 times.
930 if(temp == 0)
28882 {
28883 12 Z_scripterrlog("Script attempted to divide %ld by zero!\n", temp2);
28884 12 set_register(destreg, int32_t(sign(temp2) * MAX_SIGNED_32));
28885 12 }
28886 else
28887 {
28888 918 set_register(destreg, int32_t((temp2 * 10000) / temp));
28889 }
28890 930 }
28891
28892 252 void do_mod(bool v, const bool inv = false)
28893 {
28894 252 bool v2 = false;
28895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(inv) zc_swap(v,v2);
28896
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 auto destreg = (inv ? sarg2 : sarg1);
28897 252 int32_t temp = SH::get_arg(sarg2, v);
28898 252 int32_t temp2 = SH::get_arg(sarg1, v2);
28899
28900
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 240 times.
252 if(temp == 0)
28901 {
28902 12 Z_scripterrlog("Script attempted to modulo %ld by zero!\n",temp2);
28903 12 temp = 1;
28904 12 }
28905
28906 252 set_register(destreg, temp2 % temp);
28907 252 }
28908
28909 9370865 void do_trig(const bool v, const byte type)
28910 {
28911 9370865 double rangle = (SH::get_arg(sarg2, v) / 10000.0) * PI / 180.0;
28912
28913
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6164970 times.
✓ Branch 2 taken 3205819 times.
✓ Branch 3 taken 76 times.
9370865 switch(type)
28914 {
28915 case 0:
28916 6164970 set_register(sarg1, int32_t(zc::math::Sin(rangle) * 10000.0));
28917 6164970 break;
28918
28919 case 1:
28920 3205819 set_register(sarg1, int32_t(zc::math::Cos(rangle) * 10000.0));
28921 3205819 break;
28922
28923 case 2:
28924 76 set_register(sarg1, int32_t(zc::math::Tan(rangle) * 10000.0));
28925 76 break;
28926 }
28927 9370865 }
28928
28929 1263 void do_degtorad()
28930 {
28931 1263 double rangle = (SH::get_arg(sarg2, false) / 10000.0) * (PI / 180.0);
28932 1263 rangle += rangle < 0?-0.00005:0.00005;
28933
28934 1263 set_register(sarg1, int32_t(rangle * 10000.0));
28935 1263 }
28936
28937 60936 void do_radtodeg()
28938 {
28939 60936 double rangle = (SH::get_arg(sarg2, false) / 10000.0) * (180.0 / PI);
28940
28941 60936 set_register(sarg1, int32_t(rangle * 10000.0));
28942 60936 }
28943
28944 14918 void do_asin(const bool v)
28945 {
28946 14918 double temp = double(SH::get_arg(sarg2, v)) / 10000.0;
28947
28948
2/4
✓ Branch 0 taken 14918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14918 times.
✗ Branch 3 not taken.
14918 if(temp >= -1 && temp <= 1)
28949 14918 set_register(sarg1, int32_t(asin(temp) * 10000.0));
28950 else
28951 {
28952 Z_scripterrlog("Script attempted to pass %ld into ArcSin!\n",temp);
28953 set_register(sarg1, -10000);
28954 }
28955 14918 }
28956
28957 void do_acos(const bool v)
28958 {
28959 double temp = double(SH::get_arg(sarg2, v)) / 10000.0;
28960
28961 if(temp >= -1 && temp <= 1)
28962 set_register(sarg1, int32_t(acos(temp) * 10000.0));
28963 else
28964 {
28965 Z_scripterrlog("Script attempted to pass %ld into ArcCos!\n",temp);
28966 set_register(sarg1, -10000);
28967 }
28968 }
28969
28970 864999 void do_arctan()
28971 {
28972 864999 double xpos = ri->d[rINDEX] / 10000.0;
28973 864999 double ypos = ri->d[rINDEX2] / 10000.0;
28974
28975 864999 set_register(sarg1, int32_t(atan2(ypos, xpos) * 10000.0));
28976 864999 }
28977
28978 void do_abs(const bool v)
28979 {
28980 int32_t temp = SH::get_arg(sarg1, v);
28981 set_register(sarg1, abs(temp));
28982 }
28983
28984 27 void do_log10(const bool v)
28985 {
28986 27 double temp = double(SH::get_arg(sarg1, v)) / 10000.0;
28987
28988
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(temp > 0)
28989 27 set_register(sarg1, int32_t(log10(temp) * 10000.0));
28990 else
28991 {
28992 Z_eventlog("Script tried to calculate log of %f\n", temp / 10000.0);
28993 set_register(sarg1, 0);
28994 }
28995 27 }
28996
28997 20 void do_naturallog(const bool v)
28998 {
28999 20 double temp = double(SH::get_arg(sarg1, v)) / 10000.0;
29000
29001
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(temp > 0)
29002 20 set_register(sarg1, int32_t(log(temp) * 10000.0));
29003 // else if(temp == 0)
29004 // {
29005 // Z_eventlog("Script tried to calculate ln of 0\n");
29006 // set_register(sarg1, MIN_SIGNED_32);
29007 // }
29008 else
29009 {
29010 Z_eventlog("Script tried to calculate ln of %f\n", temp / 10000.0);
29011 set_register(sarg1, 0);
29012 }
29013 20 }
29014
29015 void do_min(const bool v)
29016 {
29017 int32_t temp = SH::get_arg(sarg2, v);
29018 int32_t temp2 = get_register(sarg1);
29019 set_register(sarg1, zc_min(temp2, temp));
29020 }
29021
29022 void do_max(const bool v)
29023 {
29024 int32_t temp = SH::get_arg(sarg2, v);
29025 int32_t temp2 = get_register(sarg1);
29026
29027 set_register(sarg1, zc_max(temp2, temp));
29028 }
29029
29030
29031 2703958 void do_rnd(const bool v)
29032 {
29033 2703958 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29034
29035
2/2
✓ Branch 0 taken 2703775 times.
✓ Branch 1 taken 183 times.
2703958 if(temp > 0)
29036 2703775 set_register(sarg1, (zc_oldrand() % temp) * 10000);
29037
1/2
✓ Branch 0 taken 183 times.
✗ Branch 1 not taken.
183 else if(temp < 0)
29038 183 set_register(sarg1, (zc_oldrand() % (-temp)) * -10000);
29039 else
29040 set_register(sarg1, 0); // Just return 0. (Do not log an error)
29041 2703958 }
29042
29043 void do_srnd(const bool v)
29044 {
29045 uint32_t seed = SH::get_arg(sarg1, v); //Do not `/10000`- allow the decimal portion to be used! -V
29046 zc_game_srand(seed);
29047 }
29048
29049 void do_srndrnd()
29050 {
29051 //Randomize the seed to the current system time, + or - the product of 2 random numbers.
29052 int32_t seed = time(0) + ((zc_rand() * int64_t(zc_rand())) * (zc_rand(1) ? 1 : -1));
29053 set_register(sarg1, seed);
29054 zc_game_srand(seed);
29055 }
29056
29057 //Returns the system Real-Time-Clock value for a specific type.
29058 void FFScript::getRTC(const bool v)
29059 {
29060 //int32_t type = get_register(sarg1) / 10000;
29061 //zprint("FFCore.getRTC() type == %d\n",type);
29062 //int32_t time = getTime(type);
29063 //zprint("FFCore.getRTC() time == %d\n",time);
29064 //zprint("FFCore.getRTC() time * 10000 == %d\n",time);
29065 //set_register(sarg1, getTime((byte)(SH::get_arg(sarg2, v) / 10000)) * 10000);
29066 set_register(sarg1, getTime((get_register(sarg1) / 10000)) * 10000);
29067 }
29068
29069
29070 void do_factorial(const bool v)
29071 {
29072 int32_t temp;
29073
29074 if(v)
29075 return; //must factorial a register, not a value (why is this exactly? ~Joe123)
29076 else
29077 {
29078 temp = get_register(sarg1) / 10000;
29079
29080 if(temp < 2)
29081 {
29082 set_register(sarg1, temp >= 0 ? 10000 : 00000);
29083 return;
29084 }
29085 }
29086
29087 int32_t temp2 = 1;
29088
29089 for(int32_t temp3 = temp; temp > 1; temp--)
29090 temp2 *= temp3;
29091
29092 set_register(sarg1, temp2 * 10000);
29093 }
29094
29095 77 void do_power(bool v, const bool inv = false)
29096 {
29097 77 bool v2 = false;
29098
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(inv) zc_swap(v,v2);
29099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 auto destreg = (inv ? sarg2 : sarg1);
29100 77 double temp = double(SH::get_arg(sarg2, v)) / 10000.0;
29101 77 double temp2 = double(SH::get_arg(sarg1, v2)) / 10000.0;
29102
29103
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
77 if(temp == 0 && temp2 == 0)
29104 {
29105 set_register(destreg, 10000);
29106 return;
29107 }
29108
29109 77 set_register(destreg, int32_t(pow(temp2, temp) * 10000.0));
29110 77 }
29111
29112 void do_lpower(bool v, const bool inv = false)
29113 {
29114 bool v2 = false;
29115 if(inv) zc_swap(v,v2);
29116 auto destreg = (inv ? sarg2 : sarg1);
29117 int32_t temp = SH::get_arg(sarg2, v);
29118 int32_t temp2 = SH::get_arg(sarg1, v2);
29119
29120 if(temp == 0 && temp2 == 0)
29121 {
29122 set_register(destreg, 1);
29123 return;
29124 }
29125
29126 set_register(destreg, int32_t(pow(temp2, temp)));
29127 }
29128
29129 //could use recursion or something to avoid truncation.
29130 void do_ipower(const bool v)
29131 {
29132 double sarg2val = double(SH::get_arg(sarg2, v));
29133 if ( sarg2val == 0 )
29134 {
29135 Z_scripterrlog("Division by 0 Err: InvPower() exponent divisor cannot be 0!!\n");
29136 set_register(sarg1, 1);
29137 return;
29138 }
29139 double temp = 10000.0 / sarg2val;
29140 double temp2 = double(get_register(sarg1)) / 10000.0;
29141
29142 if(temp == 0 && temp2 == 0)
29143 {
29144 Z_scripterrlog("Script attempted to calculate 0 to the power 0!\n");
29145 set_register(sarg1, 1);
29146 return;
29147 }
29148
29149 set_register(sarg1, int32_t(pow(temp2, temp) * 10000.0));
29150 }
29151
29152 2539388 void do_sqroot(const bool v)
29153 {
29154 2539388 double temp = double(SH::get_arg(sarg2, v)) / 10000.0;
29155
29156
2/2
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 2538966 times.
2539388 if(temp < 0)
29157 {
29158 422 Z_scripterrlog("Script attempted to calculate square root of %ld!\n", temp);
29159 422 set_register(sarg1, -10000);
29160 422 return;
29161 }
29162
29163 2538966 set_register(sarg1, int32_t(sqrt(temp) * 10000.0));
29164 2539388 }
29165
29166 ///----------------------------------------------------------------------------------------------------//
29167 //Bitwise
29168
29169 void do_and(const bool v)
29170 {
29171 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29172 int32_t temp2 = get_register(sarg1) / 10000;
29173 set_register(sarg1, (temp2 & temp) * 10000);
29174 }
29175
29176 34306 void do_and32(const bool v)
29177 {
29178 34306 int32_t temp = SH::get_arg(sarg2, v);
29179 34306 int32_t temp2 = get_register(sarg1);
29180 34306 set_register(sarg1, (temp2 & temp));
29181 34306 }
29182
29183 5736164 void do_or(const bool v)
29184 {
29185 5736164 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29186 5736164 int32_t temp2 = get_register(sarg1) / 10000;
29187 5736164 set_register(sarg1, (temp2 | temp) * 10000);
29188 5736164 }
29189
29190 17 void do_or32(const bool v)
29191 {
29192 17 int32_t temp = SH::get_arg(sarg2, v);
29193 17 int32_t temp2 = get_register(sarg1);
29194 17 set_register(sarg1, (temp2 | temp));
29195 17 }
29196
29197 191297 void do_xor(const bool v)
29198 {
29199 191297 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29200 191297 int32_t temp2 = get_register(sarg1) / 10000;
29201 191297 set_register(sarg1, (temp2 ^ temp) * 10000);
29202 191297 }
29203
29204 void do_xor32(const bool v)
29205 {
29206 int32_t temp = SH::get_arg(sarg2, v);
29207 int32_t temp2 = get_register(sarg1);
29208 set_register(sarg1, (temp2 ^ temp));
29209 }
29210
29211 void do_nand(const bool v)
29212 {
29213 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29214 int32_t temp2 = get_register(sarg1) / 10000;
29215 set_register(sarg1, (~(temp2 & temp)) * 10000);
29216 }
29217
29218 void do_nor(const bool v)
29219 {
29220 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29221 int32_t temp2 = get_register(sarg1) / 10000;
29222 set_register(sarg1, (~(temp2 | temp)) * 10000);
29223 }
29224
29225 void do_xnor(const bool v)
29226 {
29227 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29228 int32_t temp2 = get_register(sarg1) / 10000;
29229 set_register(sarg1, (~(temp2 ^ temp)) * 10000);
29230 }
29231
29232 void do_not(const bool v)
29233 {
29234 int32_t temp = SH::get_arg(sarg2, v);
29235 set_register(sarg1, !temp);
29236 }
29237
29238 1427960 void do_bitwisenot(const bool v)
29239 {
29240 1427960 int32_t temp = SH::get_arg(sarg1, v) / 10000;
29241 1427960 set_register(sarg1, (~temp) * 10000);
29242 1427960 }
29243
29244 void do_bitwisenot32(const bool v)
29245 {
29246 int32_t temp = SH::get_arg(sarg1, v);
29247 set_register(sarg1, (~temp));
29248 }
29249
29250 62844643 void do_lshift(const bool v)
29251 {
29252 62844643 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29253 62844643 int32_t temp2 = get_register(sarg1) / 10000;
29254 62844643 set_register(sarg1, (temp2 << temp) * 10000);
29255 62844643 }
29256
29257 22 void do_lshift32(const bool v)
29258 {
29259 22 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29260 22 int32_t temp2 = get_register(sarg1);
29261 22 set_register(sarg1, (temp2 << temp));
29262 22 }
29263
29264 20605908 void do_rshift(const bool v)
29265 {
29266 20605908 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29267 20605908 int32_t temp2 = get_register(sarg1) / 10000;
29268 20605908 set_register(sarg1, (temp2 >> temp) * 10000);
29269 20605908 }
29270
29271 34296 void do_rshift32(const bool v)
29272 {
29273 34296 int32_t temp = SH::get_arg(sarg2, v) / 10000;
29274 34296 int32_t temp2 = get_register(sarg1);
29275 34296 set_register(sarg1, (temp2 >> temp));
29276 34296 }
29277
29278 ///----------------------------------------------------------------------------------------------------//
29279 //Casting
29280
29281 void do_boolcast(const bool isFloat)
29282 {
29283 set_register(sarg1, (get_register(sarg1) ? (isFloat ? 1 : 10000) : 0));
29284 }
29285
29286 ///----------------------------------------------------------------------------------------------------//
29287 //Text ptr functions
29288 1259 void do_fontheight()
29289 {
29290 1259 int32_t font = get_register(sarg1)/10000;
29291 1259 ri->d[rEXP1] = text_height(get_zc_font(font))*10000;
29292 1259 }
29293
29294 13724 void do_strwidth()
29295 {
29296 13724 int32_t strptr = get_register(sarg1)/10000;
29297 13724 int32_t font = get_register(sarg2)/10000;
29298 13724 string the_string;
29299
1/2
✓ Branch 0 taken 13724 times.
✗ Branch 1 not taken.
13724 ArrayH::getString(strptr, the_string, 512);
29300
2/4
✓ Branch 0 taken 13724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13724 times.
✗ Branch 3 not taken.
13724 ri->d[rEXP1] = text_length(get_zc_font(font), the_string.c_str())*10000;
29301 13724 }
29302
29303 37547 void do_charwidth()
29304 {
29305 37547 char chr = get_register(sarg1)/10000;
29306 37547 int32_t font = get_register(sarg2)/10000;
29307 37547 char *cstr = new char[2];
29308 37547 cstr[0] = chr;
29309 37547 cstr[1] = '\0';
29310 37547 ri->d[rEXP1] = text_length(get_zc_font(font), cstr)*10000;
29311
1/2
✓ Branch 0 taken 37547 times.
✗ Branch 1 not taken.
37547 delete[] cstr;
29312 37547 }
29313
29314 int32_t do_msgwidth(int32_t msg, char const* str)
29315 {
29316 if(BC::checkMessage(msg, str) != SH::_NoError)
29317 {
29318 return -1;
29319 }
29320
29321 int32_t v = text_length(get_zc_font(MsgStrings[msg].font),
29322 MsgStrings[msg].s.substr(0,MsgStrings[msg].s.find_last_not_of(' ')+1).c_str());
29323 return v;
29324 }
29325
29326 int32_t do_msgheight(int32_t msg, char const* str)
29327 {
29328 if(BC::checkMessage(msg, str) != SH::_NoError)
29329 {
29330 return -1;
29331 }
29332 return text_height(get_zc_font(MsgStrings[msg].font));
29333 }
29334
29335 ///----------------------------------------------------------------------------------------------------//
29336 //Gameplay functions
29337
29338 79 void do_warp(bool v)
29339 {
29340 79 int32_t dmapid = SH::get_arg(sarg1, v) / 10000;
29341 79 int32_t screenid = SH::get_arg(sarg2, v) / 10000;
29342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if ( ((unsigned)dmapid) >= MAXDMAPS )
29343 {
29344 Z_scripterrlog("Invalid DMap ID (%d) passed to Warp(). Aborting.\n", dmapid);
29345 return;
29346 }
29347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if ( ((unsigned)screenid) >= MAPSCRS )
29348 {
29349 Z_scripterrlog("Invalid Screen ID (%d) passed to Warp(). Aborting.\n", screenid);
29350 return;
29351 }
29352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if ( DMaps[dmapid].map*MAPSCRS+DMaps[dmapid].xoff+screenid >= (int32_t)TheMaps.size() )
29353 {
29354 Z_scripterrlog("Invalid destination passed to Warp(). Aborting.\n");
29355 return;
29356 }
29357 79 tmpscr->sidewarpdmap[0] = dmapid;
29358 79 tmpscr->sidewarpscr[0] = screenid;
29359 79 tmpscr->sidewarptype[0] = wtIWARP;
29360 79 Hero.ffwarp = true;
29361 79 }
29362
29363 126 void do_pitwarp(bool v)
29364 {
29365 126 int32_t dmapid = SH::get_arg(sarg1, v) / 10000;
29366 126 int32_t screenid = SH::get_arg(sarg2, v) / 10000;
29367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if ( ((unsigned)dmapid) >= MAXDMAPS )
29368 {
29369 Z_scripterrlog("Invalid DMap ID (%d) passed to PitWarp(). Aborting.\n", dmapid);
29370 return;
29371 }
29372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if ( ((unsigned)screenid) >= MAPSCRS )
29373 {
29374 Z_scripterrlog("Invalid Screen ID (%d) passed to PitWarp(). Aborting.\n", screenid);
29375 return;
29376 }
29377 //Extra sanity guard.
29378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if ( DMaps[dmapid].map*MAPSCRS+DMaps[dmapid].xoff+screenid >= (int32_t)TheMaps.size() )
29379 {
29380 Z_scripterrlog("Invalid destination passed to Warp(). Aborting.\n");
29381 return;
29382 }
29383 126 tmpscr->sidewarpdmap[0] = dmapid;
29384 126 tmpscr->sidewarpscr[0] = screenid;
29385 126 tmpscr->sidewarptype[0] = wtIWARP;
29386 126 Hero.ffwarp = true;
29387 126 Hero.ffpit = true;
29388 126 }
29389
29390 void do_breakshield()
29391 {
29392 int32_t UID = get_register(sarg1);
29393
29394 for(int32_t j = 0; j < guys.Count(); j++)
29395 if(guys.spr(j)->getUID() == UID)
29396 {
29397 ((enemy*)guys.spr(j))->break_shield();
29398 return;
29399 }
29400 }
29401
29402 void do_showsavescreen()
29403 {
29404 bool didsaved = save_game(false, 0);
29405 set_register(sarg1, didsaved ? 10000 : 0);
29406 }
29407
29408 10848 void do_selectweapon(bool v, int32_t btn)
29409 {
29410
2/4
✓ Branch 0 taken 5268 times.
✓ Branch 1 taken 5580 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10848 switch(btn)
29411 {
29412 case 1:
29413
1/2
✓ Branch 0 taken 5580 times.
✗ Branch 1 not taken.
5580 if(!get_qr(qr_SELECTAWPN))
29414 return;
29415 5580 break;
29416 case 2:
29417 if(!get_qr(qr_SET_XBUTTON_ITEMS))
29418 return;
29419 break;
29420 case 3:
29421 if(!get_qr(qr_SET_YBUTTON_ITEMS))
29422 return;
29423 break;
29424 }
29425
29426 10848 byte dir=(byte)(SH::get_arg(sarg1, v)/10000);
29427
29428 // Selection directions don't match the normal ones...
29429
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
✓ Branch 4 taken 10831 times.
10848 switch(dir)
29430 {
29431 case 0:
29432 dir=SEL_UP;
29433 break;
29434
29435 case 1:
29436 dir=SEL_DOWN;
29437 break;
29438
29439 case 2:
29440 17 dir=SEL_LEFT;
29441 17 break;
29442
29443 case 3:
29444 10831 dir=SEL_RIGHT;
29445 10831 break;
29446
29447 default:
29448 return;
29449 }
29450
29451
2/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5268 times.
✓ Branch 2 taken 5580 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
10848 switch(btn)
29452 {
29453 case 0:
29454 5268 selectNextBWpn(dir);
29455 5268 break;
29456 case 1:
29457 5580 selectNextAWpn(dir);
29458 5580 break;
29459 case 2:
29460 selectNextXWpn(dir);
29461 break;
29462 case 3:
29463 selectNextYWpn(dir);
29464 break;
29465 }
29466 10848 }
29467
29468 ///----------------------------------------------------------------------------------------------------//
29469 //Screen Information
29470
29471 16274958 void do_issolid()
29472 {
29473 16274958 int32_t x = int32_t(ri->d[rINDEX] / 10000);
29474 16274958 int32_t y = int32_t(ri->d[rINDEX2] / 10000);
29475
29476 16274958 set_register(sarg1, (_walkflag(x, y, 1) ? 10000 : 0));
29477 16274958 }
29478
29479 void do_mapdataissolid()
29480 {
29481 if ( ri->mapsref == MAX_SIGNED_32 )
29482 {
29483 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","isSolid()");
29484 set_register(sarg1,10000);
29485 }
29486 else
29487 {
29488 //mapscr *m = GetMapscr(ri->mapsref);
29489 int32_t x = int32_t(ri->d[rINDEX] / 10000);
29490 int32_t y = int32_t(ri->d[rINDEX2] / 10000);
29491 switch(ri->mapsref)
29492 {
29493 case MAPSCR_TEMP0:
29494 set_register(sarg1, (_walkflag(x, y, 1)) ? 10000 : 0);
29495 break;
29496 case MAPSCR_SCROLL0:
29497 set_register(sarg1, (_walkflag(x, y, 1, FFCore.ScrollingScreens[0], FFCore.ScrollingScreens[1], FFCore.ScrollingScreens[2])) ? 10000 : 0);
29498 break;
29499 default:
29500 set_register(sarg1, (_walkflag(x, y, 1, GetMapscr(ri->mapsref)) ? 10000 : 0));
29501 }
29502 }
29503 }
29504
29505 void do_mapdataissolid_layer()
29506 {
29507 if ( ri->mapsref == MAX_SIGNED_32 )
29508 {
29509 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","isSolidLayer()");
29510 set_register(sarg1,10000);
29511 }
29512 else
29513 {
29514 //mapscr *m = GetMapscr(ri->mapsref);
29515 int32_t x = int32_t(ri->d[rINDEX] / 10000);
29516 int32_t y = int32_t(ri->d[rINDEX2] / 10000);
29517 int32_t layer = int32_t(ri->d[rEXP1] / 10000);
29518 if(BC::checkBounds(layer, 0, 6, "mapdata->isSolidLayer()") != SH::_NoError)
29519 {
29520 set_register(sarg1,10000);
29521 }
29522 else
29523 {
29524 switch(ri->mapsref)
29525 {
29526 case MAPSCR_TEMP0:
29527 set_register(sarg1, (_walkflag_layer(x, y, 1, FFCore.tempScreens[layer])) ? 10000 : 0);
29528 break;
29529 case MAPSCR_SCROLL0:
29530 set_register(sarg1, (_walkflag_layer(x, y, 1, FFCore.ScrollingScreens[layer])) ? 10000 : 0);
29531 break;
29532 default:
29533 mapscr* m = GetMapscr(ri->mapsref);
29534 if(layer > 0)
29535 {
29536 if(m->layermap[layer] == 0)
29537 {
29538 set_register(sarg1,10000);
29539 break;
29540 }
29541 m = &TheMaps[(m->layermap[layer]*MAPSCRS + m->layerscreen[layer])];
29542 }
29543 set_register(sarg1, (_walkflag_layer(x, y, 1, m) ? 10000 : 0));
29544 break;
29545 }
29546 }
29547 }
29548 }
29549
29550 void do_issolid_layer()
29551 {
29552 int32_t x = int32_t(ri->d[rINDEX] / 10000);
29553 int32_t y = int32_t(ri->d[rINDEX2] / 10000);
29554 int32_t layer = int32_t(ri->d[rEXP1] / 10000);
29555 if(BC::checkBounds(layer, 0, 6, "Screen->isSolidLayer()") != SH::_NoError)
29556 {
29557 set_register(sarg1,10000);
29558 }
29559 else
29560 {
29561 set_register(sarg1, (_walkflag_layer(x, y, 1, FFCore.tempScreens[layer])) ? 10000 : 0);
29562 }
29563 }
29564
29565 249 void do_setsidewarp()
29566 {
29567 249 int32_t warp = SH::read_stack(ri->sp + 3) / 10000;
29568 249 int32_t scrn = SH::read_stack(ri->sp + 2) / 10000;
29569 249 int32_t dmap = SH::read_stack(ri->sp + 1) / 10000;
29570 249 int32_t type = SH::read_stack(ri->sp + 0) / 10000;
29571
29572
2/4
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
498 if(BC::checkBounds(warp, -1, 3, "Screen->SetSideWarp") != SH::_NoError ||
29573
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 BC::checkBounds(scrn, -1, 0x87, "Screen->SetSideWarp") != SH::_NoError ||
29574
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 BC::checkBounds(dmap, -1, MAXDMAPS - 1, "Screen->SetSideWarp") != SH::_NoError ||
29575 249 BC::checkBounds(type, -1, wtMAX - 1, "Screen->SetSideWarp") != SH::_NoError)
29576 return;
29577
29578
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(scrn > -1)
29579 249 tmpscr->sidewarpscr[warp] = scrn;
29580
29581
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(dmap > -1)
29582 249 tmpscr->sidewarpdmap[warp] = dmap;
29583
29584
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(type > -1)
29585 249 tmpscr->sidewarptype[warp] = type;
29586 249 }
29587
29588 5 void do_settilewarp()
29589 {
29590 5 int32_t warp = SH::read_stack(ri->sp + 3) / 10000;
29591 5 int32_t scrn = SH::read_stack(ri->sp + 2) / 10000;
29592 5 int32_t dmap = SH::read_stack(ri->sp + 1) / 10000;
29593 5 int32_t type = SH::read_stack(ri->sp + 0) / 10000;
29594
29595
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
10 if(BC::checkBounds(warp, -1, 3, "Screen->SetTileWarp") != SH::_NoError ||
29596
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 BC::checkBounds(scrn, -1, 0x87, "Screen->SetTileWarp") != SH::_NoError ||
29597
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 BC::checkBounds(dmap, -1, MAXDMAPS - 1, "Screen->SetTileWarp") != SH::_NoError ||
29598 5 BC::checkBounds(type, -1, wtMAX - 1, "Screen->SetTileWarp") != SH::_NoError)
29599 return;
29600
29601
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(scrn > -1)
29602 5 tmpscr->tilewarpscr[warp] = scrn;
29603
29604
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(dmap > -1)
29605 5 tmpscr->tilewarpdmap[warp] = dmap;
29606
29607
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(type > -1)
29608 5 tmpscr->tilewarptype[warp] = type;
29609 5 }
29610
29611 354940 void do_getsidewarpdmap(const bool v)
29612 {
29613 354940 int32_t warp = SH::get_arg(sarg1, v) / 10000;
29614
29615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354940 times.
354940 if(BC::checkBounds(warp, -1, 3, "Screen->GetSideWarpDMap") != SH::_NoError)
29616 {
29617 set_register(sarg1, -10000);
29618 return;
29619 }
29620
29621 354940 set_register(sarg1, tmpscr->sidewarpdmap[warp]*10000);
29622 354940 }
29623
29624 void do_getsidewarpscr(const bool v)
29625 {
29626 int32_t warp = SH::get_arg(sarg1, v) / 10000;
29627
29628 if(BC::checkBounds(warp, -1, 3, "Screen->GetSideWarpScreen") != SH::_NoError)
29629 {
29630 set_register(sarg1, -10000);
29631 return;
29632 }
29633
29634 set_register(sarg1, tmpscr->sidewarpscr[warp]*10000);
29635 }
29636
29637 void do_getsidewarptype(const bool v)
29638 {
29639 int32_t warp = SH::get_arg(sarg1, v) / 10000;
29640
29641 if(BC::checkBounds(warp, -1, 3, "Screen->GetSideWarpType") != SH::_NoError)
29642 {
29643 set_register(sarg1, -10000);
29644 return;
29645 }
29646
29647 set_register(sarg1, tmpscr->sidewarptype[warp]*10000);
29648 }
29649
29650 354943 void do_gettilewarpdmap(const bool v)
29651 {
29652 354943 int32_t warp = SH::get_arg(sarg1, v) / 10000;
29653
29654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354943 times.
354943 if(BC::checkBounds(warp, -1, 3, "Screen->GetTileWarpDMap") != SH::_NoError)
29655 {
29656 set_register(sarg1, -10000);
29657 return;
29658 }
29659
29660 354943 set_register(sarg1, tmpscr->tilewarpdmap[warp]*10000);
29661 354943 }
29662
29663 3 void do_gettilewarpscr(const bool v)
29664 {
29665 3 int32_t warp = SH::get_arg(sarg1, v) / 10000;
29666
29667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(BC::checkBounds(warp, -1, 3, "Screen->GetTileWarpScreen") != SH::_NoError)
29668 {
29669 set_register(sarg1, -10000);
29670 return;
29671 }
29672
29673 3 set_register(sarg1, tmpscr->tilewarpscr[warp]*10000);
29674 3 }
29675
29676 3 void do_gettilewarptype(const bool v)
29677 {
29678 3 int32_t warp = SH::get_arg(sarg1, v) / 10000;
29679
29680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(BC::checkBounds(warp, -1, 3, "Screen->GetTileWarpType") != SH::_NoError)
29681 {
29682 set_register(sarg1, -10000);
29683 return;
29684 }
29685
29686 3 set_register(sarg1, tmpscr->tilewarptype[warp]*10000);
29687 3 }
29688
29689 12696160 void do_layerscreen()
29690 {
29691 12696160 int32_t layer = (get_register(sarg2) / 10000) - 1;
29692
29693
3/4
✓ Branch 0 taken 12696160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10821826 times.
✓ Branch 3 taken 1874334 times.
12696160 if(BC::checkBounds(layer, 0, 5, "Screen->LayerScreen") != SH::_NoError ||
29694 12696160 tmpscr->layermap[layer] == 0)
29695 1874334 set_register(sarg1, -10000);
29696 else
29697 10821826 set_register(sarg1, tmpscr->layerscreen[layer] * 10000);
29698 12696160 }
29699
29700 16038753 void do_layermap()
29701 {
29702 16038753 int32_t layer = (get_register(sarg2) / 10000) - 1;
29703
29704
3/4
✓ Branch 0 taken 16038753 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13868561 times.
✓ Branch 3 taken 2170192 times.
16038753 if(BC::checkBounds(layer, 0, 5, "Screen->LayerMap") != SH::_NoError ||
29705 16038753 tmpscr->layermap[layer] == 0)
29706 2170192 set_register(sarg1, -10000);
29707 else
29708 13868561 set_register(sarg1, tmpscr->layermap[layer] * 10000);
29709 16038753 }
29710
29711
29712
29713
29714 60 void do_triggersecrets()
29715 {
29716 60 hidden_entrance(0, true, false, -4);
29717 //hidden_entrance(0,true,single16,scombo);
29718 //bool findentrance(int32_t x, int32_t y, int32_t flag, bool setflag)
29719 //We need a variation on these that triggers any combos with a given flag. -Z
29720 60 }
29721
29722
29723
29724
29725 void do_getscreenflags()
29726 {
29727 int32_t map = (ri->d[rEXP1] / 10000) - 1;
29728 int32_t scrn = ri->d[rINDEX2] / 10000;
29729 int32_t flagset = ri->d[rINDEX] / 10000;
29730
29731 if(BC::checkMapID(map, "Game->GetScreenFlags") != SH::_NoError ||
29732 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenFlags") != SH::_NoError ||
29733 BC::checkBounds(flagset, 0, 9, "Game->GetScreenFlags") != SH::_NoError)
29734 return;
29735
29736 set_register(sarg1, get_screenflags(&TheMaps[map * MAPSCRS + scrn], flagset));
29737 }
29738
29739 void do_getscreeneflags()
29740 {
29741 int32_t map = (ri->d[rEXP1] / 10000) - 1;
29742 int32_t scrn = ri->d[rINDEX2] / 10000;
29743 int32_t flagset = ri->d[rINDEX] / 10000;
29744
29745 if(BC::checkMapID(map, "Game->GetScreenEFlags") != SH::_NoError ||
29746 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenEFlags") != SH::_NoError ||
29747 BC::checkBounds(flagset, 0, 9, "Game->GetScreenEFlags") != SH::_NoError)
29748 return;
29749
29750 set_register(sarg1, get_screeneflags(&TheMaps[map * MAPSCRS + scrn], flagset));
29751 }
29752
29753 void FFScript::do_graphics_getpixel()
29754 {
29755 int32_t yoffset = 0;
29756 const bool brokenOffset= ( (get_er(er_BITMAPOFFSET)!=0) || (get_qr(qr_BITMAPOFFSETFIX)!=0) );
29757 int32_t ref = (ri->d[rEXP1]);
29758
29759 if ( ref == -10000 || ref == -20000 || ref >= 10000 ) //Bitmaps Loaded by LoadBitmapID have values of -10000 to 70000
29760 {
29761 ref /= 10000;
29762 }
29763 else ref -= 10; //Bitmaps other than those loaded by LoadBitmapID
29764
29765 BITMAP *bitty = FFCore.GetScriptBitmap(ref);
29766 int32_t xpos = ri->d[rINDEX2] / 10000;
29767
29768 if(!brokenOffset && ref == -1 )
29769 {
29770 yoffset = 56; //should this be -56?
29771 }
29772 else
29773 {
29774 yoffset = 0;
29775 }
29776
29777 int32_t ypos = (ri->d[rINDEX] / 10000)+yoffset;
29778 if(!bitty)
29779 {
29780 bitty = scrollbuf;
29781 }
29782
29783 int32_t ret = getpixel(bitty, xpos, ypos); //This is a palette index value.
29784
29785 if(!get_qr(qr_BROKEN_GETPIXEL_VALUE))
29786 ret *= 10000;
29787 set_register(sarg1, ret);
29788 }
29789
29790 //Some of these need to be reduced to two inputs. -Z
29791
29792 int32_t get_screendoor(mapscr *m, int32_t d)
29793 {
29794 int32_t f = m->door[d];
29795 return f*10000;
29796 }
29797
29798
29799
29800 int32_t get_screenlayeropacity(mapscr *m, int32_t d)
29801 {
29802 int32_t f = m->layeropacity[d]; //6 of these
29803 return f*10000;
29804 }
29805
29806 int32_t get_screensecretcombo(mapscr *m, int32_t d)
29807 {
29808 int32_t f = m->secretcombo[d]; //128 of these
29809 return f*10000;
29810 }
29811
29812 int32_t get_screensecretcset(mapscr *m, int32_t d)
29813 {
29814 int32_t f = m->secretcset[d]; //128 of these
29815 return f*10000;
29816 }
29817
29818 int32_t get_screensecretflag(mapscr *m, int32_t d)
29819 {
29820 int32_t f = m->secretflag[d]; //128 of these
29821 return f*10000;
29822 }
29823
29824 int32_t get_screenlayermap(mapscr *m, int32_t d)
29825 {
29826 int32_t f = m->layermap[d]; //6 of these
29827 return f*10000;
29828 }
29829
29830 int32_t get_screenlayerscreen(mapscr *m, int32_t d)
29831 {
29832 int32_t f = m->layerscreen[d]; //6 of these
29833 return f*10000;
29834 }
29835
29836 int32_t get_screenpath(mapscr *m, int32_t d)
29837 {
29838 int32_t f = m->path[d]; //4 of these
29839 return f*10000;
29840 }
29841
29842 int32_t get_screenwarpReturnX(mapscr *m, int32_t d)
29843 {
29844 int32_t f = m->warpreturnx[d]; //4 of these
29845 return f*10000;
29846 }
29847
29848 int32_t get_screenwarpReturnY(mapscr *m, int32_t d)
29849 {
29850 int32_t f = m->warpreturny[d]; //4 of these
29851 return f*10000;
29852 }
29853 //One too many inputs here. -Z
29854 int32_t get_screenGuy(mapscr *m)
29855 {
29856 int32_t f = m->guy;
29857 return f*10000;
29858 }
29859 //One too many inputs here. -Z
29860 int32_t get_screenString(mapscr *m)
29861 {
29862 int32_t f = m->str;
29863 return f*10000;
29864 }
29865 //One too many inputs here. -Z
29866 int32_t get_screenRoomtype(mapscr *m)
29867 {
29868 int32_t f = m->room;
29869 return f*10000;
29870 }
29871 //One too many inputs here. -Z
29872 int32_t get_screenEntryX(mapscr *m)
29873 {
29874 int32_t f = m->entry_x;
29875 return f*10000;
29876 }
29877 //One too many inputs here. -Z
29878 int32_t get_screenEntryY(mapscr *m)
29879 {
29880 int32_t f = m->entry_y;
29881 return f*10000;
29882 }
29883 //One too many inputs here. -Z
29884 int32_t get_screenitem(mapscr *m)
29885 {
29886 int32_t f = m->item;
29887 return f*10000;
29888 }
29889 //One too many inputs here. -Z
29890 int32_t get_screenundercombo(mapscr *m)
29891 {
29892 int32_t f = m->undercombo;
29893 return f*10000;
29894 }
29895 //One too many inputs here. -Z
29896 int32_t get_screenundercset(mapscr *m)
29897 {
29898 int32_t f = m->undercset;
29899 return f*10000;
29900 }
29901 //One too many inputs here. -Z
29902 int32_t get_screenatchall(mapscr *m)
29903 {
29904 int32_t f = m->catchall;
29905 return f*10000;
29906 }
29907 void do_getscreenLayerOpacity()
29908 {
29909 int32_t map = (ri->d[rEXP1] / 10000) - 1;
29910 int32_t scrn = ri->d[rINDEX2] / 10000;
29911 int32_t d = ri->d[rINDEX] / 10000;
29912
29913 if(BC::checkMapID(map, "Game->GetLayerOpacity(...map...)") != SH::_NoError ||
29914 BC::checkBounds(scrn, 0, 0x87, "Game->GetLayerOpacity(...screen...)") != SH::_NoError ||
29915 BC::checkBounds(d, 0, 6, "Game->GetLayerOpacity(...val...)") != SH::_NoError)
29916 return;
29917
29918 set_register(sarg1, get_screenlayeropacity(&TheMaps[map * MAPSCRS + scrn], d));
29919 }
29920 void do_getscreenSecretCombo()
29921 {
29922 int32_t map = (ri->d[rEXP1] / 10000) - 1;
29923 int32_t scrn = ri->d[rINDEX2] / 10000;
29924 int32_t d = ri->d[rINDEX] / 10000;
29925
29926 if(BC::checkMapID(map, "Game->GetSecretCombo(...map...)") != SH::_NoError ||
29927 BC::checkBounds(scrn, 0, 0x87, "Game->GetSecretCombo(...screen...)") != SH::_NoError ||
29928 BC::checkBounds(d, 0, 127, "Game->GetSecretCombo(...val...)") != SH::_NoError)
29929 return;
29930
29931 set_register(sarg1, get_screensecretcombo(&TheMaps[map * MAPSCRS + scrn], d));
29932 }
29933
29934 void do_getscreenSecretCSet()
29935 {
29936 int32_t map = (ri->d[rEXP1] / 10000) - 1;
29937 int32_t scrn = ri->d[rINDEX2] / 10000;
29938 int32_t d = ri->d[rINDEX] / 10000;
29939
29940 if(BC::checkMapID(map, "Game->GetSecretCSet(...map...)") != SH::_NoError ||
29941 BC::checkBounds(scrn, 0, 0x87, "Game->GetSecretCSet(...screen...)") != SH::_NoError ||
29942 BC::checkBounds(d, 0, 127, "Game->GetSecretCSet(...val...)") != SH::_NoError)
29943 return;
29944
29945 set_register(sarg1, get_screensecretcset(&TheMaps[map * MAPSCRS + scrn], d));
29946 }
29947
29948 void do_getscreenSecretFlag()
29949 {
29950 int32_t map = (ri->d[rEXP1] / 10000) - 1;
29951 int32_t scrn = ri->d[rINDEX2] / 10000;
29952 int32_t d = ri->d[rINDEX] / 10000;
29953
29954 if(BC::checkMapID(map, "Game->GetSecretFlag(...map...)") != SH::_NoError ||
29955 BC::checkBounds(scrn, 0, 0x87, "Game->GetSecretFlag(...screen...)") != SH::_NoError ||
29956 BC::checkBounds(d, 0,127, "Game->GetSecretFlag(...val...)") != SH::_NoError)
29957 return;
29958
29959 set_register(sarg1, get_screensecretflag(&TheMaps[map * MAPSCRS + scrn], d));
29960 }
29961 void do_getscreenLayerMap()
29962 {
29963 int32_t map = (ri->d[rEXP1] / 10000) - 1;
29964 int32_t scrn = ri->d[rINDEX2] / 10000;
29965 int32_t d = ri->d[rINDEX] / 10000;
29966
29967 if(BC::checkMapID(map, "Game->GetSreenLayerMap(...map...)") != SH::_NoError ||
29968 BC::checkBounds(scrn, 0, 0x87, "Game->GetSreenLayerMap(...screen...)") != SH::_NoError ||
29969 BC::checkBounds(d, 0, 6, "Game->GetSreenLayerMap(...val...)") != SH::_NoError)
29970 return;
29971
29972 set_register(sarg1, get_screenlayermap(&TheMaps[map * MAPSCRS + scrn], d));
29973 }
29974 void do_getscreenLayerscreen()
29975 {
29976 int32_t map = (ri->d[rEXP1] / 10000) - 1;
29977 int32_t scrn = ri->d[rINDEX2] / 10000;
29978 int32_t d = ri->d[rINDEX] / 10000;
29979
29980 if(BC::checkMapID(map, "Game->GetSreenLayerScreen(...map...)") != SH::_NoError ||
29981 BC::checkBounds(scrn, 0, 0x87, "Game->GetSreenLayerScreen(...screen...)") != SH::_NoError ||
29982 BC::checkBounds(d, 0, 6, "Game->GetSreenLayerScreen(...val...)") != SH::_NoError)
29983 return;
29984
29985 set_register(sarg1, get_screenlayerscreen(&TheMaps[map * MAPSCRS + scrn], d));
29986 }
29987 void do_getscreenPath()
29988 {
29989 int32_t map = (ri->d[rEXP1] / 10000) - 1;
29990 int32_t scrn = ri->d[rINDEX2] / 10000;
29991 int32_t d = ri->d[rINDEX] / 10000;
29992
29993 if(BC::checkMapID(map, "Game->GetSreenPath(...map...)") != SH::_NoError ||
29994 BC::checkBounds(scrn, 0, 0x87, "Game->GetSreenPath(...screen...)") != SH::_NoError ||
29995 BC::checkBounds(d, 0, 3, "Game->GetSreenPath(...val...)") != SH::_NoError)
29996 return;
29997
29998 set_register(sarg1, get_screenpath(&TheMaps[map * MAPSCRS + scrn], d));
29999 }
30000 void do_getscreenWarpReturnX()
30001 {
30002 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30003 int32_t scrn = ri->d[rINDEX2] / 10000;
30004 int32_t d = ri->d[rINDEX] / 10000;
30005
30006 if(BC::checkMapID(map, "Game->GetScreenWarpReturnX(...map...)") != SH::_NoError ||
30007 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenWarpReturnX(...screen...)") != SH::_NoError ||
30008 BC::checkBounds(d, 0, 3, "Game->GetScreenWarpReturnX(...val...)") != SH::_NoError)
30009 return;
30010
30011 set_register(sarg1, get_screenwarpReturnX(&TheMaps[map * MAPSCRS + scrn], d));
30012 }
30013 void do_getscreenWarpReturnY()
30014 {
30015 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30016 int32_t scrn = ri->d[rINDEX2] / 10000;
30017 int32_t d = ri->d[rINDEX] / 10000;
30018
30019 if(BC::checkMapID(map, "Game->GetScreenWarpReturnY(...map...)") != SH::_NoError ||
30020 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenWarpReturnY(...screen...)") != SH::_NoError ||
30021 BC::checkBounds(d, 0, 3, "Game->GetScreenWarpReturnY(...val...)") != SH::_NoError)
30022 return;
30023
30024 set_register(sarg1, get_screenwarpReturnY(&TheMaps[map * MAPSCRS + scrn], d));
30025 }
30026
30027 /*
30028 //One too many inputs here. -Z
30029 void do_getscreenatchall()
30030 {
30031 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30032 int32_t scrn = ri->d[rINDEX2] / 10000;
30033 int32_t d = ri->d[rINDEX] / 10000;
30034
30035 if(BC::checkMapID(map, "Game->GetScreenCatchall(...map...)") != SH::_NoError ||
30036 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenCatchall(...screen...)") != SH::_NoError ||
30037 BC::checkBounds(d, 0, 6, "Game->GetScreenCatchall(...val...)") != SH::_NoError)
30038 return;
30039
30040 set_register(sarg1, get_screenatchall(&TheMaps[map * MAPSCRS + scrn], d));
30041 }
30042
30043
30044 //One too many inputs here. -Z
30045 void do_getscreenUndercombo()
30046 {
30047 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30048 int32_t scrn = ri->d[rINDEX2] / 10000;
30049 int32_t d = ri->d[rINDEX] / 10000;
30050
30051 if(BC::checkMapID(map, "Game->GetcreenUndercombo(...map...)") != SH::_NoError ||
30052 BC::checkBounds(scrn, 0, 0x87, "Game->GetcreenUndercombo(...screen...)") != SH::_NoError ||
30053 BC::checkBounds(d, 0, 6, "Game->GetcreenUndercombo(...val...)") != SH::_NoError)
30054 return;
30055
30056 set_register(sarg1, get_screenundercombo(&TheMaps[map * MAPSCRS + scrn], d));
30057 }
30058 //One too many inputs here. -Z
30059 void do_getscreenUnderCSet()
30060 {
30061 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30062 int32_t scrn = ri->d[rINDEX2] / 10000;
30063 int32_t d = ri->d[rINDEX] / 10000;
30064
30065 if(BC::checkMapID(map, "Game->GeScreenUnderCSet(...map...)") != SH::_NoError ||
30066 BC::checkBounds(scrn, 0, 0x87, "Game->GeScreenUnderCSet(...screen...)") != SH::_NoError ||
30067 BC::checkBounds(d, 0, 6, "Game->GeScreenUnderCSet(...val...)") != SH::_NoError)
30068 return;
30069
30070 set_register(sarg1, get_screenundercset(&TheMaps[map * MAPSCRS + scrn], d));
30071 }
30072
30073 //One too many inputs here. -Z
30074 void do_getscreenGuy()
30075 {
30076 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30077 int32_t scrn = ri->d[rINDEX2] / 10000;
30078 int32_t d = ri->d[rINDEX] / 10000;
30079
30080 if(BC::checkMapID(map, "Game->GetScreenGuy(...map...)") != SH::_NoError ||
30081 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenGuy(...screen...)") != SH::_NoError ||
30082 BC::checkBounds(d, 0, 214747, "Game->GetScreenGuy(...val...)") != SH::_NoError)
30083 return;
30084
30085 set_register(sarg1, get_screenGuy(&TheMaps[map * MAPSCRS + scrn], d));
30086 }
30087 //One too many inputs here. -Z
30088 void do_getscreenString()
30089 {
30090 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30091 int32_t scrn = ri->d[rINDEX2] / 10000;
30092 int32_t d = ri->d[rINDEX] / 10000;
30093
30094 if(BC::checkMapID(map, "Game->GetScreenString(...map...)") != SH::_NoError ||
30095 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenString(...screen...)") != SH::_NoError ||
30096 BC::checkBounds(d, 0, 214747, "Game->GetScreenString(...val...)") != SH::_NoError)
30097 return;
30098
30099 set_register(sarg1, get_screenString(&TheMaps[map * MAPSCRS + scrn], d));
30100 }
30101 //One too many inputs here. -Z
30102 void do_getscreenRoomType()
30103 {
30104 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30105 int32_t scrn = ri->d[rINDEX2] / 10000;
30106 int32_t d = ri->d[rINDEX] / 10000;
30107
30108 if(BC::checkMapID(map, "Game->GetScreenRoomType(...map...)") != SH::_NoError ||
30109 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenRoomType(...screen...)") != SH::_NoError ||
30110 BC::checkBounds(d, 0, 214747, "Game->GetScreenRoomType(...val...)") != SH::_NoError)
30111 return;
30112
30113 set_register(sarg1, get_screenRoomtype(&TheMaps[map * MAPSCRS + scrn], d));
30114 }
30115 //One too many inputs here. -Z
30116 void do_getscreenEntryX()
30117 {
30118 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30119 int32_t scrn = ri->d[rINDEX2] / 10000;
30120 int32_t d = ri->d[rINDEX] / 10000;
30121
30122 if(BC::checkMapID(map, "Game->GetScreenEntryX(...map...)") != SH::_NoError ||
30123 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenEntryX(...screen...)") != SH::_NoError ||
30124 BC::checkBounds(d, 0, 214747, "Game->GetScreenEntryX(...val...)") != SH::_NoError)
30125 return;
30126
30127 set_register(sarg1, get_screenEntryX(&TheMaps[map * MAPSCRS + scrn], d));
30128 }
30129 //One too many inputs here. -Z
30130 void do_getscreenEntryY()
30131 {
30132 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30133 int32_t scrn = ri->d[rINDEX2] / 10000;
30134 int32_t d = ri->d[rINDEX] / 10000;
30135
30136 if(BC::checkMapID(map, "Game->GetScreenEntryY(...map...)") != SH::_NoError ||
30137 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenEntryY(...screen...)") != SH::_NoError ||
30138 BC::checkBounds(d, 0, 214747, "Game->GetScreenEntryY(...val...)") != SH::_NoError)
30139 return;
30140
30141 set_register(sarg1, get_screenEntryY(&TheMaps[map * MAPSCRS + scrn], d));
30142 }
30143 //One too many inputs here. -Z
30144 void do_getscreenItem()
30145 {
30146 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30147 int32_t scrn = ri->d[rINDEX2] / 10000;
30148 int32_t d = ri->d[rINDEX] / 10000;
30149
30150 if(BC::checkMapID(map, "Game->GetScreenItem(...map...)") != SH::_NoError ||
30151 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenItem(...screen...)") != SH::_NoError ||
30152 BC::checkBounds(d, 0, 255, "Game->GetScreenItem(...val...)") != SH::_NoError)
30153 return;
30154
30155 set_register(sarg1, get_screenitem(&TheMaps[map * MAPSCRS + scrn], d));
30156 }
30157 */
30158 void do_getscreendoor()
30159 {
30160 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30161 int32_t scrn = ri->d[rINDEX2] / 10000;
30162 int32_t door = ri->d[rINDEX] / 10000;
30163
30164 if(BC::checkMapID(map, "Game->GetScreenDoor(...map...)") != SH::_NoError ||
30165 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenDoor(...screen...)") != SH::_NoError ||
30166 BC::checkBounds(door, 0, 3, "Game->GetScreenDoor(...doorindex...)") != SH::_NoError)
30167 return;
30168
30169 set_register(sarg1, get_screendoor(&TheMaps[map * MAPSCRS + scrn], door));
30170 }
30171
30172 int32_t get_screennpc(mapscr *m, int32_t index)
30173 {
30174 int32_t f = m->enemy[index];
30175 return f*10000;
30176 }
30177
30178
30179 void do_getscreennpc()
30180 {
30181 int32_t map = (ri->d[rEXP1] / 10000) - 1;
30182 int32_t scrn = ri->d[rINDEX2] / 10000;
30183 int32_t enemy = ri->d[rINDEX] / 10000;
30184
30185 if(BC::checkMapID(map, "Game->GetScreenEnemy(...map...)") != SH::_NoError ||
30186 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenEnemy(...screen...)") != SH::_NoError ||
30187 BC::checkBounds(enemy, 0, 9, "Game->GetScreenEnemy(...enemy...)") != SH::_NoError)
30188 return;
30189
30190 set_register(sarg1, get_screennpc(&TheMaps[map * MAPSCRS + scrn], enemy));
30191 }
30192
30193
30194 ///----------------------------------------------------------------------------------------------------//
30195 //Pointer handling
30196
30197 565 void do_isvalidarray()
30198 {
30199 565 int32_t ptr = get_register(sarg1)/10000;
30200
30201 565 set_register(sarg1,0);
30202
30203
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(!ptr) return;
30204
30205
1/2
✓ Branch 0 taken 565 times.
✗ Branch 1 not taken.
565 if(ptr < 0) //An object array?
30206 {
30207 int32_t objptr = -ptr;
30208 auto it = objectRAM.find(objptr);
30209 if(it == objectRAM.end())
30210 return;
30211 set_register(sarg1,10000);
30212 }
30213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 else if(ptr >= NUM_ZSCRIPT_ARRAYS) //check global
30214 {
30215 dword gptr = ptr - NUM_ZSCRIPT_ARRAYS;
30216
30217 if(gptr > game->globalRAM.size())
30218 return;
30219 else set_register(sarg1,game->globalRAM[gptr].Valid() ? 10000 : 0);
30220 }
30221 else
30222 {
30223 565 set_register(sarg1,localRAM[ptr].Valid() ? 10000 : 0);
30224 }
30225 565 }
30226
30227 27033 void do_isvaliditem()
30228 {
30229 27033 int32_t IID = get_register(sarg1);
30230 //int32_t ct = items.Count();
30231
30232 //for ( int32_t j = items.Count()-1; j >= 0; --j )
30233
2/2
✓ Branch 0 taken 30321 times.
✓ Branch 1 taken 203 times.
30524 for(int32_t j = 0; j < items.Count(); j++)
30234 //for(int32_t j = 0; j < ct; j++)
30235
2/2
✓ Branch 0 taken 26830 times.
✓ Branch 1 taken 3491 times.
30321 if(items.spr(j)->getUID() == IID)
30236 {
30237 26830 set_register(sarg1, 10000);
30238 26830 return;
30239 }
30240
30241 203 set_register(sarg1, 0);
30242 27033 }
30243
30244 6266198 void do_isvalidnpc()
30245 {
30246 6266198 int32_t UID = get_register(sarg1);
30247 //for ( int32_t j = guys.Count()-1; j >= 0; --j )
30248 //int32_t ct = guys.Count();
30249
30250
2/2
✓ Branch 0 taken 20581357 times.
✓ Branch 1 taken 99922 times.
20681279 for(int32_t j = 0; j < guys.Count(); j++)
30251 //for(int32_t j = 0; j < ct; j++)
30252
2/2
✓ Branch 0 taken 6166276 times.
✓ Branch 1 taken 14415081 times.
20581357 if(guys.spr(j)->getUID() == UID)
30253 {
30254 6166276 set_register(sarg1, 10000);
30255 6166276 return;
30256 }
30257
30258 99922 set_register(sarg1, 0);
30259 6266198 }
30260
30261 593592 void do_isvalidlwpn()
30262 {
30263 593592 int32_t WID = get_register(sarg1);
30264 //int32_t ct = Lwpns.Count();
30265
30266 //for ( int32_t j = Lwpns.Count()-1; j >= 0; --j )
30267
2/2
✓ Branch 0 taken 2892378 times.
✓ Branch 1 taken 47556 times.
2939934 for(int32_t j = 0; j < Lwpns.Count(); j++)
30268 //for(int32_t j = 0; j < ct; j++)
30269
2/2
✓ Branch 0 taken 546036 times.
✓ Branch 1 taken 2346342 times.
2892378 if(Lwpns.spr(j)->getUID() == WID)
30270 {
30271 546036 set_register(sarg1, 10000);
30272 546036 return;
30273 }
30274
30275 47556 set_register(sarg1, 0);
30276 593592 }
30277
30278 122622 void do_isvalidewpn()
30279 {
30280 122622 int32_t WID = get_register(sarg1);
30281 // int32_t ct = Ewpns.Count();
30282
30283 // for ( int32_t j = Ewpns.Count()-1; j >= 0; --j )
30284
2/2
✓ Branch 0 taken 596698 times.
✓ Branch 1 taken 23727 times.
620425 for(int32_t j = 0; j < Ewpns.Count(); j++)
30285 //for(int32_t j = 0; j < ct; j++)
30286
2/2
✓ Branch 0 taken 98895 times.
✓ Branch 1 taken 497803 times.
596698 if(Ewpns.spr(j)->getUID() == WID)
30287 {
30288 98895 set_register(sarg1, 10000);
30289 98895 return;
30290 }
30291
30292 23727 set_register(sarg1, 0);
30293 122622 }
30294
30295 void do_lwpnmakeangular()
30296 {
30297 if(LwpnH::loadWeapon(ri->lwpn, "lweapon->MakeAngular") == SH::_NoError)
30298 {
30299 if (!LwpnH::getWeapon()->angular)
30300 {
30301 double vx;
30302 double vy;
30303 switch(NORMAL_DIR(LwpnH::getWeapon()->dir))
30304 {
30305 case l_up:
30306 case l_down:
30307 case left:
30308 vx = -1.0*((weapon*)s)->step;
30309 break;
30310 case r_down:
30311 case r_up:
30312 case right:
30313 vx = ((weapon*)s)->step;
30314 break;
30315
30316 default:
30317 vx = 0;
30318 break;
30319 }
30320 switch(NORMAL_DIR(LwpnH::getWeapon()->dir))
30321 {
30322 case l_up:
30323 case r_up:
30324 case up:
30325 vy = -1.0*((weapon*)s)->step;
30326 break;
30327 case l_down:
30328 case r_down:
30329 case down:
30330 vy = ((weapon*)s)->step;
30331 break;
30332
30333 default:
30334 vy = 0;
30335 break;
30336 }
30337 LwpnH::getWeapon()->angular = true;
30338 LwpnH::getWeapon()->angle=atan2(vy, vx);
30339 LwpnH::getWeapon()->step=FFCore.Distance(0, 0, vx, vy)/10000.0;
30340 LwpnH::getWeapon()->doAutoRotate();
30341 }
30342 }
30343 }
30344
30345 void do_lwpnmakedirectional()
30346 {
30347 if(LwpnH::loadWeapon(ri->lwpn, "lweapon->MakeDirectional") == SH::_NoError)
30348 {
30349 if (LwpnH::getWeapon()->angular)
30350 {
30351 LwpnH::getWeapon()->dir = NORMAL_DIR(AngleToDir(WrapAngle(LwpnH::getWeapon()->angle)));
30352 LwpnH::getWeapon()->angular = false;
30353 LwpnH::getWeapon()->doAutoRotate(true);
30354 }
30355 }
30356 }
30357
30358 void do_ewpnmakeangular()
30359 {
30360 if(EwpnH::loadWeapon(ri->ewpn, "eweapon->MakeAngular") == SH::_NoError)
30361 {
30362 if (!EwpnH::getWeapon()->angular)
30363 {
30364 double vx;
30365 double vy;
30366 switch(NORMAL_DIR(EwpnH::getWeapon()->dir))
30367 {
30368 case l_up:
30369 case l_down:
30370 case left:
30371 vx = -1.0*((weapon*)s)->step;
30372 break;
30373 case r_down:
30374 case r_up:
30375 case right:
30376 vx = ((weapon*)s)->step;
30377 break;
30378
30379 default:
30380 vx = 0;
30381 break;
30382 }
30383 switch(NORMAL_DIR(EwpnH::getWeapon()->dir))
30384 {
30385 case l_up:
30386 case r_up:
30387 case up:
30388 vy = -1.0*((weapon*)s)->step;
30389 break;
30390 case l_down:
30391 case r_down:
30392 case down:
30393 vy = ((weapon*)s)->step;
30394 break;
30395
30396 default:
30397 vy = 0;
30398 break;
30399 }
30400 EwpnH::getWeapon()->angular = true;
30401 EwpnH::getWeapon()->angle=atan2(vy, vx);
30402 EwpnH::getWeapon()->step=FFCore.Distance(0, 0, vx, vy)/10000.0;
30403 EwpnH::getWeapon()->doAutoRotate();
30404 }
30405 }
30406 }
30407
30408 void do_ewpnmakedirectional()
30409 {
30410 if(EwpnH::loadWeapon(ri->lwpn, "eweapon->MakeDirectional") == SH::_NoError)
30411 {
30412 if (EwpnH::getWeapon()->angular)
30413 {
30414 EwpnH::getWeapon()->dir = NORMAL_DIR(AngleToDir(WrapAngle(EwpnH::getWeapon()->angle)));
30415 EwpnH::getWeapon()->angular = false;
30416 EwpnH::getWeapon()->doAutoRotate(true);
30417 }
30418 }
30419 }
30420
30421 15079 void do_lwpnusesprite(const bool v)
30422 {
30423 15079 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30424
30425
1/2
✓ Branch 0 taken 15079 times.
✗ Branch 1 not taken.
15079 if(BC::checkWeaponMiscSprite(ID, "lweapon->UseSprite") != SH::_NoError)
30426 return;
30427
30428
1/2
✓ Branch 0 taken 15079 times.
✗ Branch 1 not taken.
15079 if(LwpnH::loadWeapon(ri->lwpn, "lweapon->UseSprite") == SH::_NoError)
30429 15079 LwpnH::getWeapon()->LOADGFX(ID);
30430 15079 }
30431
30432 132144 void do_ewpnusesprite(const bool v)
30433 {
30434 132144 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30435
30436
1/2
✓ Branch 0 taken 132144 times.
✗ Branch 1 not taken.
132144 if(BC::checkWeaponMiscSprite(ID, "eweapon->UseSprite") != SH::_NoError)
30437 return;
30438
30439
1/2
✓ Branch 0 taken 132144 times.
✗ Branch 1 not taken.
132144 if(EwpnH::loadWeapon(ri->ewpn, "eweapon->UseSprite") == SH::_NoError)
30440 132144 EwpnH::getWeapon()->LOADGFX(ID);
30441 132144 }
30442
30443 void do_portalusesprite()
30444 {
30445 int32_t ID = get_register(sarg1) / 10000;
30446
30447 if(BC::checkWeaponMiscSprite(ID, "portal->UseSprite") != SH::_NoError)
30448 return;
30449
30450 if(portal* p = checkPortal(ri->portalref, "UseSprite()"))
30451 p->LOADGFX(ID);
30452 }
30453
30454 void do_clearsprites(const bool v)
30455 {
30456 int32_t spritelist = SH::get_arg(sarg1, v) / 10000;
30457
30458 if(BC::checkBounds(spritelist, 0, 5, "Screen->ClearSprites") != SH::_NoError)
30459 return;
30460
30461 switch(spritelist)
30462 {
30463 case 0:
30464 guys.clear();
30465 break;
30466
30467 case 1:
30468 items.clear();
30469 break;
30470
30471 case 2:
30472 Ewpns.clear();
30473 break;
30474
30475 case 3:
30476 Lwpns.clear();
30477 Hero.reset_hookshot();
30478 break;
30479
30480 case 4:
30481 decorations.clear();
30482 break;
30483
30484 case 5:
30485 particles.clear();
30486 break;
30487 }
30488 }
30489
30490 1201098 void do_loadlweapon(const bool v)
30491 {
30492 1201098 int32_t index = SH::get_arg(sarg1, v) / 10000;
30493
30494
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 1187342 times.
1201098 if(BC::checkLWeaponIndex(index, "Screen->LoadLWeapon") != SH::_NoError)
30495 13756 ri->lwpn = 0; //MAX_DWORD; //Now NULL
30496 else
30497 {
30498 1187342 ri->lwpn = Lwpns.spr(index)->getUID();
30499 // This is too trivial to log. -L
30500 //Z_eventlog("Script loaded lweapon with UID = %ld\n", ri->lwpn);
30501 }
30502 1201098 }
30503
30504 2753647 void do_loadeweapon(const bool v)
30505 {
30506 2753647 int32_t index = SH::get_arg(sarg1, v) / 10000;
30507
30508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2753647 times.
2753647 if(BC::checkEWeaponIndex(index, "Screen->LoadEWeapon") != SH::_NoError)
30509 ri->ewpn = 0; //MAX_DWORD; //Now NULL
30510 else
30511 {
30512 2753647 ri->ewpn = Ewpns.spr(index)->getUID();
30513 //Z_eventlog("Script loaded eweapon with UID = %ld\n", ri->ewpn);
30514 }
30515 2753647 }
30516
30517 136832 void do_loaditem(const bool v)
30518 {
30519 136832 int32_t index = SH::get_arg(sarg1, v) / 10000;
30520
30521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136832 times.
136832 if(BC::checkItemIndex(index, "Screen->LoadItem") != SH::_NoError)
30522 ri->itemref = 0; //MAX_DWORD; //Now NULL
30523 else
30524 {
30525 136832 ri->itemref = items.spr(index)->getUID();
30526 //Z_eventlog("Script loaded item with UID = %ld\n", ri->itemref);
30527 }
30528 136832 }
30529
30530
30531 1816935 void do_loaditemdata(const bool v)
30532 {
30533 1816935 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30534
30535 //I *think* this is the right check ~Joe
30536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1816935 times.
1816935 if(BC::checkItemID(ID, "Game->LoadItemData") != SH::_NoError)
30537 {
30538 ri->idata = -1; //new null value
30539 return;
30540 }
30541 1816935 ri->idata = ID;
30542 //Z_eventlog("Script loaded itemdata with ID = %ld\n", ri->idata);
30543 1816935 }
30544
30545 15644354 void do_loadnpc(const bool v)
30546 {
30547 15644354 int32_t index = SH::get_arg(sarg1, v) / 10000;
30548
30549
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 15644273 times.
15644354 if(BC::checkGuyIndex(index, "Screen->LoadNPC") != SH::_NoError)
30550 81 ri->guyref = 0; // MAX_DWORD;
30551 else
30552 {
30553 15644273 ri->guyref = guys.spr(index)->getUID();
30554 //Z_eventlog("Script loaded NPC with UID = %ld\n", ri->guyref);
30555 }
30556 15644354 }
30557
30558 802539 void FFScript::do_loaddmapdata(const bool v)
30559 {
30560 802539 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30561
30562
2/4
✓ Branch 0 taken 802539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 802539 times.
802539 if ( ID < 0 || ID > 511 )
30563 {
30564 Z_scripterrlog("Invalid DMap ID passed to Game->LoadDMapData(): %d\n", ID);
30565 ri->dmapsref = MAX_DWORD;
30566 }
30567 802539 else ri->dmapsref = ID;
30568 802539 }
30569
30570 void FFScript::do_load_active_subscreendata(const bool v)
30571 {
30572 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30573
30574 if(ID == -1 || (unsigned(ID) < subscreens_active.size() && unsigned(ID) < 256))
30575 {
30576 ri->subdataref = get_subref(ID, sstACTIVE);
30577 }
30578 else
30579 {
30580 Z_scripterrlog("Invalid Subscreen ID passed to Game->LoadASubData(): %d\n", ID);
30581 ri->subdataref = 0;
30582 }
30583 ri->d[rEXP1] = ri->subdataref;
30584 }
30585 void FFScript::do_load_passive_subscreendata(const bool v)
30586 {
30587 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30588
30589 if(ID == -1 || (unsigned(ID) < subscreens_passive.size() && unsigned(ID) < 256))
30590 {
30591 ri->subdataref = get_subref(ID, sstPASSIVE);
30592 }
30593 else
30594 {
30595 Z_scripterrlog("Invalid Subscreen ID passed to Game->LoadPSubData(): %d\n", ID);
30596 ri->subdataref = 0;
30597 }
30598 ri->d[rEXP1] = ri->subdataref;
30599 }
30600 void FFScript::do_load_overlay_subscreendata(const bool v)
30601 {
30602 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30603
30604 if(ID == -1 || (unsigned(ID) < subscreens_overlay.size() && unsigned(ID) < 256))
30605 {
30606 ri->subdataref = get_subref(ID, sstOVERLAY);
30607 }
30608 else
30609 {
30610 Z_scripterrlog("Invalid Subscreen ID passed to Game->LoadOSubData(): %d\n", ID);
30611 ri->subdataref = 0;
30612 }
30613 ri->d[rEXP1] = ri->subdataref;
30614 }
30615 void FFScript::do_load_subscreendata(const bool v, const bool v2)
30616 {
30617 int32_t ty = SH::get_arg(sarg2, v2) / 10000;
30618 switch(ty)
30619 {
30620 case sstACTIVE:
30621 do_load_active_subscreendata(v);
30622 break;
30623 case sstPASSIVE:
30624 do_load_passive_subscreendata(v);
30625 break;
30626 case sstOVERLAY:
30627 do_load_overlay_subscreendata(v);
30628 break;
30629 default:
30630 {
30631 Z_scripterrlog("Invalid Subscreen Type passed to ???: %d\n", ty);
30632 ri->subdataref = 0;
30633 break;
30634 }
30635 }
30636 ri->d[rEXP1] = ri->subdataref;
30637 }
30638
30639 22 void FFScript::do_loadrng()
30640 {
30641 22 ri->rngref = get_free_rng();
30642 22 ri->d[rEXP1] = ri->rngref;
30643 22 }
30644
30645 void FFScript::do_loaddirectory()
30646 {
30647 int32_t arrayptr = get_register(sarg1) / 10000;
30648 string path;
30649 ArrayH::getString(arrayptr, path, 2048);
30650
30651 if(path.find("../") != string::npos
30652 || path.find("..\\") != string::npos)
30653 {
30654 Z_scripterrlog("Error: Script attempted to go up a directory in directory load '%s'\n", path.c_str());
30655 return;
30656 }
30657
30658 size_t pos = path.find_last_not_of("/\\");
30659 if(pos != string::npos && !(path.find_last_of("/\\") < pos))
30660 path = path.substr(0, pos+1);
30661 char buf[2048+1] = {0};
30662 get_scriptfile_path(buf, path.c_str());
30663 regulate_path(buf);
30664 if(valid_dir(buf) && checkPath(buf, true))
30665 {
30666 ri->directoryref = get_free_directory(false);
30667 if(!ri->directoryref) return;
30668 user_dir* d = checkDir(ri->directoryref, "LoadDirectory", true);
30669 set_register(sarg1, ri->directoryref);
30670 d->setPath(buf);
30671 return;
30672 }
30673 Z_scripterrlog("Path '%s' empty or points to a file; must point to a directory!\n",path.c_str());
30674 ri->directoryref = 0;
30675 set_register(sarg1, 0);
30676 }
30677
30678 void FFScript::do_loadstack()
30679 {
30680 ri->stackref = get_free_stack();
30681 ri->d[rEXP1] = ri->stackref;
30682 }
30683
30684 void FFScript::do_loaddropset(const bool v)
30685 {
30686 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30687
30688 if ( ID < 0 || ID > MAXITEMDROPSETS )
30689 {
30690 Z_scripterrlog("Invalid Dropset ID passed to Game->LoadDropset(): %d\n", ID);
30691 ri->dropsetref = MAX_DWORD;
30692 }
30693
30694 else ri->dropsetref = ID;
30695 }
30696
30697 void FFScript::do_loadbottle(const bool v)
30698 {
30699 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30700
30701 if ( ID < 1 || ID > 64 )
30702 {
30703 Z_scripterrlog("Invalid BottleType ID passed to Game->LoadBottleData(): %d\n", ID);
30704 ri->bottletyperef = 0;
30705 }
30706 else ri->bottletyperef = ID;
30707 }
30708
30709 void FFScript::do_loadbottleshop(const bool v)
30710 {
30711 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30712
30713 if ( ID < 0 || ID > 255 )
30714 {
30715 Z_scripterrlog("Invalid BottleShopType ID passed to Game->LoadBottleShopData(): %d\n", ID);
30716 ri->bottleshopref = 0;
30717 }
30718 else ri->bottleshopref = ID+1;
30719 }
30720 68 void FFScript::do_loadgenericdata(const bool v)
30721 {
30722 68 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30723
30724
2/4
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 68 times.
68 if ( ID < 1 || ID > NUMSCRIPTSGENERIC )
30725 {
30726 Z_scripterrlog("Invalid GenericData ID passed to Game->LoadGenericData(): %d\n", ID);
30727 ri->genericdataref = 0;
30728 }
30729 68 else ri->genericdataref = ID;
30730 68 }
30731
30732 void FFScript::do_create_paldata()
30733 {
30734 ri->paldataref = get_free_paldata();
30735 user_paldata* pd = &script_paldatas[ri->paldataref-1];
30736 for (int32_t q = 0; q < PALDATA_BITSTREAM_SIZE; ++q)
30737 pd->colors_used[q] = 0;
30738 ri->d[rEXP1] = ri->paldataref;
30739 }
30740
30741 void FFScript::do_create_paldata_clr()
30742 {
30743 ri->paldataref = get_free_paldata();
30744 user_paldata* pd = &script_paldatas[ri->paldataref - 1];
30745 int32_t clri = get_register(sarg1);
30746
30747 RGB c = _RGB((clri >> 16) & 0xFF, (clri >> 8) & 0xFF, clri & 0xFF);
30748
30749 if (c.r < 0 || c.g < 0 || c.b < 0)
30750 {
30751 Z_scripterrlog("Invalid rgb (%d) passed to Graphics->CreatePalData().\n", clri);
30752 }
30753 c.r = vbound(c.r, 0, 63);
30754 c.g = vbound(c.g, 0, 63);
30755 c.b = vbound(c.b, 0, 63);
30756
30757 for(int32_t q = 0; q < 240; ++q)
30758 pd->set_color(q, c);
30759 ri->d[rEXP1] = ri->paldataref;
30760 }
30761
30762 void FFScript::do_mix_clr()
30763 {
30764 int32_t clr_start = SH::read_stack(ri->sp + 3);
30765 int32_t clr_end = SH::read_stack(ri->sp + 2);
30766 float percent = SH::read_stack(ri->sp + 1) / 10000.0;
30767 int32_t color_space = SH::read_stack(ri->sp + 0) / 10000;
30768
30769 RGB ref1c = _RGB((clr_start >> 16) & 0xFF, (clr_start >> 8) & 0xFF, clr_start & 0xFF);
30770 RGB ref2c = _RGB((clr_end >> 16) & 0xFF, (clr_end >> 8) & 0xFF, clr_end & 0xFF);
30771 RGB outputc = user_paldata::mix_color(ref1c, ref2c, percent, color_space);
30772
30773 int32_t r = vbound(outputc.r, 0, 63);
30774 int32_t g = vbound(outputc.g, 0, 63);
30775 int32_t b = vbound(outputc.b, 0, 63);
30776
30777 ri->d[rEXP1] = (r << 16) | (g << 8) | b;
30778 }
30779
30780 void FFScript::do_create_rgb_hex()
30781 {
30782 int32_t hexrgb = get_register(sarg1);
30783
30784 int32_t r = (hexrgb >> 16) & 0xFF;
30785 int32_t g = (hexrgb >> 8) & 0xFF;
30786 int32_t b = hexrgb & 0xFF;
30787
30788 //Convert rgb from 8-bit to 6-bit
30789 r = vbound(r / 4, 0, 63);
30790 g = vbound(g / 4, 0, 63);
30791 b = vbound(b / 4, 0, 63);
30792
30793 ri->d[rEXP1] = (r << 16) | (g << 8) | b;
30794 }
30795
30796 void FFScript::do_create_rgb()
30797 {
30798 int32_t r = SH::read_stack(ri->sp + 2) / 10000;
30799 int32_t g = SH::read_stack(ri->sp + 1) / 10000;
30800 int32_t b = SH::read_stack(ri->sp + 0) / 10000;
30801
30802 if (unsigned(r) > 63 || unsigned(g) > 63 || unsigned(b) > 63)
30803 {
30804 Z_scripterrlog("R/G/B values passed to Graphics->CreateRGB() should range from 0-63.\n");
30805 }
30806 r = vbound(r, 0, 63);
30807 g = vbound(g, 0, 63);
30808 b = vbound(b, 0, 63);
30809
30810 ri->d[rEXP1] = (r << 16) | (g << 8) | b;
30811 }
30812
30813 void FFScript::do_convert_from_rgb()
30814 {
30815 int32_t buf = SH::read_stack(ri->sp + 2) / 10000;
30816 int32_t clri = SH::read_stack(ri->sp + 1);
30817 int32_t color_space = SH::read_stack(ri->sp + 0) / 10000;
30818
30819 ArrayManager am(buf);
30820 if (am.invalid()) return;
30821 int32_t zscript_array_size = am.size();
30822 int32_t target_size;
30823
30824 switch (color_space)
30825 {
30826 case user_paldata::CSPACE_CMYK:
30827 target_size = 4;
30828 break;
30829 default:
30830 target_size = 3;
30831 }
30832
30833 if (zscript_array_size < target_size)
30834 {
30835 Z_scripterrlog("Array supplied to 'Graphics->ConvertFromRGB' not large enough. Should be at least size %d\n", target_size);
30836 return;
30837 }
30838
30839 RGB c = _RGB((clri >> 16) & 0xFF, (clri >> 8) & 0xFF, clri & 0xFF);
30840 double convert[4];
30841 user_paldata::RGBTo(c, convert, color_space);
30842
30843 for (int32_t q = 0; q < target_size; ++q)
30844 {
30845 am.set(q, int32_t(convert[q]*10000));
30846 }
30847
30848 return;
30849 }
30850
30851 void FFScript::do_convert_to_rgb()
30852 {
30853 int32_t buf = SH::read_stack(ri->sp + 1) / 10000;
30854 int32_t color_space = SH::read_stack(ri->sp + 0) / 10000;
30855
30856 ArrayManager am(buf);
30857 if (am.invalid()) return;
30858 int32_t zscript_array_size = am.size();
30859 int32_t target_size;
30860
30861 switch (color_space)
30862 {
30863 case user_paldata::CSPACE_CMYK:
30864 target_size = 4;
30865 break;
30866 default:
30867 target_size = 3;
30868 }
30869
30870 if (zscript_array_size < target_size)
30871 {
30872 Z_scripterrlog("Array supplied to 'Graphics->ConvertToRGB' not large enough. Should be at least size %d\n", target_size);
30873 return;
30874 }
30875
30876 double convert[4];
30877 for (int32_t q = 0; q < target_size; ++q)
30878 {
30879 convert[q] = am.get(q) / 10000.0;
30880 }
30881 RGB c = user_paldata::RGBFrom(convert, color_space);
30882
30883 ri->d[rEXP1] = (c.r << 16) | (c.g << 8) | c.b;
30884 }
30885
30886 void FFScript::do_paldata_load_level()
30887 {
30888 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->LoadLevelPalette()"))
30889 {
30890 int32_t lvl = get_register(sarg1) / 10000;
30891 //Load CSets 2-4
30892 pd->load_cset(2, lvl * pdLEVEL + poLEVEL + 0);
30893 pd->load_cset(3, lvl * pdLEVEL + poLEVEL + 1);
30894 pd->load_cset(4, lvl * pdLEVEL + poLEVEL + 2);
30895 //Load CSet 9
30896 pd->load_cset(9, lvl * pdLEVEL + poLEVEL + 3);
30897 //Load 1, 5, 7, 8
30898 pd->load_cset(1, lvl * pdLEVEL + poNEWCSETS);
30899 pd->load_cset(5, lvl * pdLEVEL + poNEWCSETS + 1);
30900 pd->load_cset(7, lvl * pdLEVEL + poNEWCSETS + 2);
30901 pd->load_cset(8, lvl * pdLEVEL + poNEWCSETS + 3);
30902 }
30903 return;
30904 }
30905
30906 void FFScript::do_paldata_load_sprite()
30907 {
30908 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->LoadSpritePalette()"))
30909 {
30910 int32_t page = get_register(sarg1) / 10000;
30911
30912 int32_t pageoffset = 0;
30913 switch (page)
30914 {
30915 case 0: pageoffset += 0; break;
30916 case 1: pageoffset += 15; break;
30917 default:
30918 Z_scripterrlog("Invalid page (%d) passed to paldata->LoadSpritePalette(). Valid pages are 0 or 1. Aborting.\n", page);
30919 return;
30920 }
30921 for (int32_t q = 0; q < 15; ++q)
30922 {
30923 pd->load_cset(q, poSPRITE255 + pageoffset + q);
30924 }
30925 }
30926 return;
30927 }
30928
30929 void FFScript::do_paldata_load_main()
30930 {
30931 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->LoadMainPalette()"))
30932 {
30933 for (int32_t q = 0; q <= 15; ++q)
30934 {
30935 pd->load_cset_main(q);
30936 }
30937 }
30938 return;
30939 }
30940
30941 void FFScript::do_paldata_load_cycle()
30942 {
30943 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->LoadCyclePalette()"))
30944 {
30945 int32_t lvl = get_register(sarg1) / 10000;
30946 for (int32_t q = 4; q <= 12; ++q)
30947 {
30948 pd->load_cset(q, lvl * pdLEVEL + poLEVEL + q);
30949 }
30950 }
30951 return;
30952 }
30953
30954 void FFScript::do_paldata_load_bitmap()
30955 {
30956 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->LoadBitmapPalette()"))
30957 {
30958 int32_t pathptr = get_register(sarg1) / 10000;
30959 string str;
30960 ArrayH::getString(pathptr, str, 256);
30961
30962 if (get_qr(qr_BITMAP_AND_FILESYSTEM_PATHS_ALWAYS_RELATIVE))
30963 {
30964 char buf[2048+1] = { 0 };
30965 if (FFCore.get_scriptfile_path(buf, str.c_str()))
30966 str = buf;
30967 }
30968 regulate_path(str);
30969
30970 if (str.empty())
30971 {
30972 al_trace("String pointer is null! Internal error. \n");
30973 return;
30974 }
30975
30976 PALETTE tempPal;
30977 get_palette(tempPal);
30978 if (checkPath(str.c_str(), false))
30979 {
30980 BITMAP* bmp = load_bitmap(str.c_str(), tempPal);
30981 if (!bmp)
30982 {
30983 Z_scripterrlog("LoadBitmapPalette() failed to load image file %s.\n", str.c_str());
30984 }
30985 else
30986 {
30987 for (int32_t q = 0; q < PALDATA_NUM_COLORS; ++q)
30988 {
30989 pd->colors[q] = tempPal[q];
30990 set_bit(pd->colors_used, q, true);
30991 }
30992 }
30993 destroy_bitmap(bmp);
30994 }
30995 else
30996 {
30997 Z_scripterrlog("Failed to load image file: %s. File not found.\n", str.c_str());
30998 }
30999 }
31000 return;
31001 }
31002
31003 void FFScript::do_paldata_write_level()
31004 {
31005 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteLevelPalette()"))
31006 {
31007 int32_t lvl = get_register(sarg1) / 10000;
31008 bool changed = false;
31009 //Write CSets 2-4
31010 if (pd->check_cset(2, lvl * pdLEVEL + poLEVEL + 0))
31011 {
31012 pd->write_cset(2, lvl * pdLEVEL + poLEVEL + 0);
31013 changed = true;
31014 }
31015 if (pd->check_cset(3, lvl * pdLEVEL + poLEVEL + 1))
31016 {
31017 pd->write_cset(3, lvl * pdLEVEL + poLEVEL + 1);
31018 changed = true;
31019 }
31020 if (pd->check_cset(4, lvl * pdLEVEL + poLEVEL + 2))
31021 {
31022 pd->write_cset(4, lvl * pdLEVEL + poLEVEL + 2);
31023 changed = true;
31024 }
31025 //Write CSet 9
31026 if (pd->check_cset(9, lvl * pdLEVEL + poLEVEL + 3))
31027 {
31028 pd->write_cset(9, lvl * pdLEVEL + poLEVEL + 3);
31029 changed = true;
31030 }
31031 //Write 1, 5, 7, 8
31032 if (pd->check_cset(1, lvl * pdLEVEL + poNEWCSETS + 0))
31033 {
31034 pd->write_cset(1, lvl * pdLEVEL + poNEWCSETS + 0);
31035 changed = true;
31036 }
31037 if (pd->check_cset(5, lvl * pdLEVEL + poNEWCSETS + 1))
31038 {
31039 pd->write_cset(5, lvl * pdLEVEL + poNEWCSETS + 1);
31040 changed = true;
31041 }
31042 if (pd->check_cset(7, lvl * pdLEVEL + poNEWCSETS + 2))
31043 {
31044 pd->write_cset(7, lvl * pdLEVEL + poNEWCSETS + 2);
31045 changed = true;
31046 }
31047 if (pd->check_cset(8, lvl * pdLEVEL + poNEWCSETS + 3))
31048 {
31049 pd->write_cset(8, lvl * pdLEVEL + poNEWCSETS + 3);
31050 changed = true;
31051 }
31052
31053 if (changed && DMaps[currdmap].color == lvl)
31054 {
31055 loadlvlpal(lvl);
31056 currcset = lvl;
31057 if (darkroom && !get_qr(qr_NEW_DARKROOM))
31058 {
31059 if (get_qr(qr_FADE))
31060 {
31061 interpolatedfade();
31062 }
31063 else
31064 {
31065 loadfadepal((DMaps[currdmap].color) * pdLEVEL + poFADE3);
31066 }
31067 }
31068 }
31069 }
31070 return;
31071 }
31072
31073 void FFScript::do_paldata_write_levelcset()
31074 {
31075 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteLevelCSet()"))
31076 {
31077 int32_t lvl = get_register(sarg1) / 10000;
31078 int32_t cs = get_register(sarg2) / 10000;
31079
31080 bool changed = false;
31081
31082 switch (cs)
31083 {
31084 case 1:
31085 if (pd->check_cset(1, lvl * pdLEVEL + poNEWCSETS + 0))
31086 {
31087 pd->write_cset(1, lvl * pdLEVEL + poNEWCSETS + 0);
31088 changed = true;
31089 }
31090 break;
31091 case 2:
31092 if (pd->check_cset(2, lvl * pdLEVEL + poLEVEL + 0))
31093 {
31094 pd->write_cset(2, lvl * pdLEVEL + poLEVEL + 0);
31095 changed = true;
31096 }
31097 break;
31098 case 3:
31099 if (pd->check_cset(3, lvl * pdLEVEL + poLEVEL + 1))
31100 {
31101 pd->write_cset(3, lvl * pdLEVEL + poLEVEL + 1);
31102 changed = true;
31103 }
31104 break;
31105 case 4:
31106 if (pd->check_cset(4, lvl * pdLEVEL + poLEVEL + 2))
31107 {
31108 pd->write_cset(4, lvl * pdLEVEL + poLEVEL + 2);
31109 changed = true;
31110 }
31111 break;
31112 case 5:
31113 if (pd->check_cset(5, lvl * pdLEVEL + poNEWCSETS + 1))
31114 {
31115 pd->write_cset(5, lvl * pdLEVEL + poNEWCSETS + 1);
31116 changed = true;
31117 }
31118 break;
31119 case 7:
31120 if (pd->check_cset(7, lvl * pdLEVEL + poNEWCSETS + 2))
31121 {
31122 pd->write_cset(7, lvl * pdLEVEL + poNEWCSETS + 2);
31123 changed = true;
31124 }
31125 break;
31126 case 8:
31127 if (pd->check_cset(8, lvl * pdLEVEL + poNEWCSETS + 3))
31128 {
31129 pd->write_cset(8, lvl * pdLEVEL + poNEWCSETS + 3);
31130 changed = true;
31131 }
31132 break;
31133 case 9:
31134 if (pd->check_cset(9, lvl * pdLEVEL + poLEVEL + 3))
31135 {
31136 pd->write_cset(9, lvl * pdLEVEL + poLEVEL + 3);
31137 changed = true;
31138 }
31139 break;
31140 default:
31141 Z_scripterrlog("Invalid CSet (%d) passed to 'paldata->WriteLevelCSet()'. Level palettes can use CSets 1, 2, 3, 4, 5, 7, 8, 9.\n");
31142 return;
31143 }
31144
31145 if (changed && DMaps[currdmap].color == lvl)
31146 {
31147 loadlvlpal(lvl);
31148 if (darkroom && !get_qr(qr_NEW_DARKROOM))
31149 {
31150 if (get_qr(qr_FADE))
31151 {
31152 interpolatedfade();
31153 }
31154 else
31155 {
31156 loadfadepal((DMaps[currdmap].color) * pdLEVEL + poFADE3);
31157 }
31158 }
31159 currcset = lvl;
31160 }
31161 }
31162 }
31163
31164 void FFScript::do_paldata_write_sprite()
31165 {
31166 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteSpritePalette()"))
31167 {
31168 int32_t page = get_register(sarg1) / 10000;
31169
31170 int32_t pageoffset = 0;
31171 switch (page)
31172 {
31173 case 0: pageoffset += 0; break;
31174 case 1: pageoffset += 15; break;
31175 default:
31176 Z_scripterrlog("Invalid page (%d) passed to paldata->WriteSpritePalette(). Valid pages are 0 or 1. Aborting.\n", page);
31177 return;
31178 }
31179 bool changed6 = false;
31180 bool changed14 = false;
31181 for (int32_t q = 0; q < 15; ++q)
31182 {
31183 if (pd->check_cset(q, poSPRITE255 + pageoffset + q))
31184 {
31185 pd->write_cset(q, poSPRITE255 + pageoffset + q);
31186 if (pageoffset + q == currspal6)
31187 {
31188 changed6 = true;
31189 }
31190 if (pageoffset + q == currspal14)
31191 {
31192 changed14 = true;
31193 }
31194 }
31195 }
31196
31197 //If either sprite palette has been changed, update the main palette
31198 if (changed6 || changed14)
31199 {
31200 if (changed6)
31201 {
31202 loadpalset(6, poSPRITE255 + currspal6, false);
31203 }
31204 if (changed14)
31205 {
31206 loadpalset(14, poSPRITE255 + currspal14, false);
31207 }
31208
31209 if (isMonochrome()) {
31210 if (lastMonoPreset) {
31211 restoreMonoPreset();
31212 }
31213 else {
31214 setMonochrome(false);
31215 setMonochrome(true);
31216 }
31217 }
31218
31219 if (isUserTinted()) {
31220 restoreTint();
31221 }
31222 }
31223 }
31224 return;
31225 }
31226
31227 void FFScript::do_paldata_write_spritecset()
31228 {
31229 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteSpritePalette()"))
31230 {
31231 int32_t page = get_register(sarg1) / 10000;
31232 int32_t cs = get_register(sarg2) / 10000;
31233
31234 int32_t pageoffset = 0;
31235 switch (page)
31236 {
31237 case 0: pageoffset += 0; break;
31238 case 1: pageoffset += 15; break;
31239 default:
31240 Z_scripterrlog("Invalid page (%d) passed to paldata->WriteSpriteCSet(). Valid pages are 0 or 1. Aborting.\n", page);
31241 return;
31242 }
31243 bool changed6 = false;
31244 bool changed14 = false;
31245 if (unsigned(cs) > 15)
31246 {
31247 Z_scripterrlog("Invalid CSet (%d) passed to paldata->WriteSpriteCSet(). Valid CSets are 0-15. Aborting.\n", cs);
31248 return;
31249 }
31250 if (pd->check_cset(cs, poSPRITE255 + pageoffset + cs))
31251 {
31252 pd->write_cset(cs, poSPRITE255 + pageoffset + cs);
31253 if (pageoffset + cs == currspal6)
31254 {
31255 changed6 = true;
31256 }
31257 if (pageoffset + cs == currspal14)
31258 {
31259 changed14 = true;
31260 }
31261 }
31262
31263 //If either sprite palette has been changed, update the main palette
31264 if (changed6 || changed14)
31265 {
31266 if (changed6)
31267 {
31268 loadpalset(6, poSPRITE255 + currspal6, false);
31269 }
31270 if (changed14)
31271 {
31272 loadpalset(14, poSPRITE255 + currspal14, false);
31273 }
31274
31275 if (isMonochrome()) {
31276 if (lastMonoPreset) {
31277 restoreMonoPreset();
31278 }
31279 else {
31280 setMonochrome(false);
31281 setMonochrome(true);
31282 }
31283 }
31284
31285 if (isUserTinted()) {
31286 restoreTint();
31287 }
31288 }
31289 }
31290 return;
31291 }
31292
31293 void FFScript::do_paldata_write_main()
31294 {
31295 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteMainPalette()"))
31296 {
31297 bool changed = false;
31298 for (int32_t q = 0; q <= 15; ++q)
31299 {
31300 if (pd->check_cset_main(q))
31301 {
31302 pd->write_cset_main(q);
31303 changed = true;
31304 }
31305 }
31306
31307 if (changed)
31308 {
31309 refreshpal = true;
31310 }
31311 }
31312 return;
31313 }
31314
31315 void FFScript::do_paldata_write_maincset()
31316 {
31317 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteMainCSet()"))
31318 {
31319 int32_t cs = get_register(sarg1) / 10000;
31320
31321 bool changed = false;
31322
31323 if (unsigned(cs) < 16)
31324 {
31325 if (pd->check_cset_main(cs))
31326 {
31327 pd->write_cset_main(cs);
31328 changed = true;
31329 }
31330 }
31331 else
31332 {
31333 Z_scripterrlog("Invalid CSet (%d) passed to 'paldata->WriteMainCSet()'. Valid csets are 0-15. Aborting.\n");
31334 return;
31335 }
31336
31337 if (changed)
31338 {
31339 refreshpal = true;
31340 }
31341 }
31342 }
31343
31344 void FFScript::do_paldata_write_cycle()
31345 {
31346 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteCyclePalette()"))
31347 {
31348 int32_t lvl = get_register(sarg1) / 10000;
31349 for (int32_t q = 4; q <= 12; ++q)
31350 {
31351 if (pd->check_cset(q, lvl * pdLEVEL + poLEVEL + q))
31352 {
31353 pd->write_cset(q, lvl * pdLEVEL + poLEVEL + q);
31354 }
31355 }
31356 }
31357 return;
31358 }
31359
31360 void FFScript::do_paldata_write_cyclecset()
31361 {
31362 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteCycleCSet()"))
31363 {
31364 int32_t lvl = get_register(sarg1) / 10000;
31365 int32_t cs = get_register(sarg2) / 10000;
31366
31367 bool changed = false;
31368
31369 switch (cs)
31370 {
31371 case 4:
31372 case 5:
31373 case 6:
31374 case 7:
31375 case 8:
31376 case 9:
31377 case 10:
31378 case 11:
31379 case 12:
31380 if (pd->check_cset(cs, lvl * pdLEVEL + poLEVEL + cs))
31381 {
31382 pd->write_cset(cs, lvl * pdLEVEL + poLEVEL + cs);
31383 changed = true;
31384 }
31385 break;
31386 default:
31387 Z_scripterrlog("Invalid CSet (%d) passed to 'paldata->WriteCycleCSet()'. Cycle palettes use CSets 4-12.\n");
31388 return;
31389 }
31390
31391 if (changed && DMaps[currdmap].color == lvl)
31392 {
31393 loadlvlpal(lvl);
31394 currcset = lvl;
31395 }
31396 }
31397 }
31398
31399 void FFScript::do_paldata_colorvalid()
31400 {
31401 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->ColorValid()"))
31402 {
31403 int32_t ind = get_register(sarg1) / 10000;
31404 if (unsigned(ind) >= PALDATA_NUM_COLORS)
31405 {
31406 Z_scripterrlog("Invalid color index (%d) passed to paldata->ColorValid(). Valid indices are 0-255.\n", ind);
31407 set_register(sarg1, 0);
31408 return;
31409 }
31410
31411 if (get_bit(pd->colors_used, ind))
31412 {
31413 set_register(sarg1, 10000);
31414 }
31415 else
31416 {
31417 set_register(sarg1, 0);
31418 }
31419 }
31420 }
31421
31422 void FFScript::do_paldata_clearcolor()
31423 {
31424 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->SetColor()"))
31425 {
31426 int32_t ind = get_register(sarg1) / 10000;
31427 if (unsigned(ind) >= PALDATA_NUM_COLORS)
31428 {
31429 Z_scripterrlog("Invalid color index (%d) passed to paldata->ClearColor(). Valid indices are 0-255. Aborting.\n", ind);
31430 return;
31431 }
31432 set_bit(pd->colors_used, ind, false);
31433 }
31434 }
31435
31436 void FFScript::do_paldata_clearcset()
31437 {
31438 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->ClearCSet()"))
31439 {
31440 int32_t cs = get_register(sarg1) / 10000;
31441 if (unsigned(cs) > 15)
31442 {
31443 Z_scripterrlog("Invalid cset (%d) passed to paldata->ClearCSet(). Valid csets are 0-15. Aborting.\n", cs);
31444 return;
31445 }
31446 for (int32_t q = 0; q < 16; ++q)
31447 {
31448 set_bit(pd->colors_used, CSET(cs) + q, false);
31449 }
31450 }
31451 }
31452
31453 int32_t FFScript::do_paldata_getrgb(int32_t v)
31454 {
31455 const char* fname = "";
31456 switch (v)
31457 {
31458 case 0: fname = "paldata->R[]"; break;
31459 case 1: fname = "paldata->G[]"; break;
31460 case 2: fname = "paldata->B[]"; break;
31461 }
31462 if (user_paldata* pd = checkPalData(ri->paldataref, fname))
31463 {
31464 int32_t ind = ri->d[rINDEX] / 10000;
31465 if (unsigned(ind) >= PALDATA_NUM_COLORS)
31466 {
31467 Z_scripterrlog("Invalid color index (%d) passed to %s. Valid indices are 0-255.\n", ind, fname);
31468 return -10000;
31469 }
31470 if (!get_bit(pd->colors_used, ind))
31471 {
31472 Z_scripterrlog("%s tried to access unused color %d.\n", fname, ind);
31473 return -10000;
31474 }
31475 switch (v)
31476 {
31477 case 0:
31478 return pd->colors[ind].r * 10000;
31479 case 1:
31480 return pd->colors[ind].g * 10000;
31481 case 2:
31482 return pd->colors[ind].b * 10000;
31483 }
31484 }
31485 return -10000;
31486 }
31487
31488 void FFScript::do_paldata_setrgb(int32_t v, int32_t val)
31489 {
31490 const char* fname = "";
31491 switch (v)
31492 {
31493 case 0: fname = "paldata->R[]"; break;
31494 case 1: fname = "paldata->G[]"; break;
31495 case 2: fname = "paldata->B[]"; break;
31496 }
31497 if (user_paldata* pd = checkPalData(ri->paldataref, fname))
31498 {
31499 int32_t ind = ri->d[rINDEX] / 10000;
31500 if (unsigned(ind) >= PALDATA_NUM_COLORS)
31501 {
31502 Z_scripterrlog("Invalid color index (%d) passed to %s. Valid indices are 0-255. Aborting.\n", ind, fname);
31503 return;
31504 }
31505 if (unsigned(val) > 63)
31506 {
31507 Z_scripterrlog("RGB value(%d) passed to %s is out of range. RGB values range from 0 - 63.\n", val, fname);
31508 val = vbound(val, 0, 63);
31509 }
31510 if (!get_bit(pd->colors_used, ind))
31511 {
31512 Z_scripterrlog("%s tried to access unused color %d.\n", fname, ind);
31513 return;
31514 }
31515 switch (v)
31516 {
31517 case 0:
31518 pd->colors[ind].r = val;
31519 break;
31520 case 1:
31521 pd->colors[ind].g = val;
31522 break;
31523 case 2:
31524 pd->colors[ind].b = val;
31525 break;
31526 }
31527 }
31528 }
31529
31530 void FFScript::do_paldata_mix()
31531 {
31532 int32_t ref = SH::read_stack(ri->sp + 4);
31533 if (user_paldata* pd = checkPalData(ref, "paldata->Mix()"))
31534 {
31535 int32_t ref1 = SH::read_stack(ri->sp + 3);
31536 int32_t ref2 = SH::read_stack(ri->sp + 2);
31537 double percent = SH::read_stack(ri->sp + 1)/10000.0;
31538 int32_t color_space = SH::read_stack(ri->sp + 0)/10000;
31539 if (user_paldata* pd_start = checkPalData(ref1, "paldata->Mix()"))
31540 {
31541 if (user_paldata* pd_end = checkPalData(ref2, "paldata->Mix()"))
31542 {
31543 pd->mix(pd_start, pd_end, percent, color_space);
31544 }
31545 }
31546 }
31547 }
31548
31549 void FFScript::do_paldata_mixcset()
31550 {
31551 int32_t ref = SH::read_stack(ri->sp + 5);
31552 if (user_paldata* pd = checkPalData(ref, "paldata->MixCSet()"))
31553 {
31554 int32_t ref1 = SH::read_stack(ri->sp + 4);
31555 int32_t ref2 = SH::read_stack(ri->sp + 3);
31556 int32_t cset = SH::read_stack(ri->sp + 2) / 10000;
31557 double percent = SH::read_stack(ri->sp + 1) / 10000.0;
31558 int32_t color_space = SH::read_stack(ri->sp + 0) / 10000;
31559 if (user_paldata* pd_start = checkPalData(ref1, "paldata->MixCSet()"))
31560 {
31561 if (user_paldata* pd_end = checkPalData(ref2, "paldata->MixCSet()"))
31562 {
31563 if (unsigned(cset) > 15)
31564 {
31565 Z_scripterrlog("CSet passed to 'paldata->MixCSet()' out of range. Valid CSets are 0-15\n");
31566 return;
31567 }
31568 pd->mix(pd_start, pd_end, percent, color_space, CSET(cset), CSET(cset) + 16);
31569 }
31570 }
31571 }
31572 }
31573
31574 void FFScript::do_paldata_copy()
31575 {
31576 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->Copy()"))
31577 {
31578 int32_t ref_dest = get_register(sarg1);
31579 if (user_paldata* pd_dest = checkPalData(ref_dest, "paldata->Copy()"))
31580 {
31581 for (int32_t q = 0; q < PALDATA_NUM_COLORS; ++q)
31582 {
31583 pd_dest->colors[q] = pd->colors[q];
31584 }
31585 for (int32_t q = 0; q < PALDATA_BITSTREAM_SIZE; ++q)
31586 {
31587 pd_dest->colors_used[q] = pd->colors_used[q];
31588 }
31589 }
31590 }
31591 }
31592
31593 void FFScript::do_paldata_copycset()
31594 {
31595 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->CopyCSet()"))
31596 {
31597 int32_t ref_dest = SH::read_stack(ri->sp + 2);
31598 int32_t cs = SH::read_stack(ri->sp + 1) / 10000;
31599 int32_t cs_dest = SH::read_stack(ri->sp + 0) / 10000;
31600 if (user_paldata* pd_dest = checkPalData(ref_dest, "paldata->CopyCSet()"))
31601 {
31602 if (unsigned(cs) > 15)
31603 {
31604 Z_scripterrlog("Invalid CSet (%d) passed to paldata->CopyCSet(). Valid CSets are 0-15. Aborting.\n", cs);
31605 return;
31606 }
31607 for (int32_t q = 0; q < 16; ++q)
31608 {
31609 pd_dest->colors[CSET(cs_dest) + q] = pd->colors[CSET(cs) + q];
31610 set_bit(pd_dest->colors_used, CSET(cs_dest) + q, bool(get_bit(pd->colors_used, CSET(cs) + q)));
31611 }
31612 }
31613 }
31614 }
31615
31616 //Loads a cset to paldata from memory
31617 void user_paldata::load_cset(int32_t cset, int32_t dataset)
31618 {
31619 byte* si = colordata + CSET(dataset) * 3;
31620 for (int32_t q = 0; q < 16; ++q)
31621 {
31622 int32_t ind = CSET(cset) + q;
31623 colors[ind].r = si[0];
31624 colors[ind].g = si[1];
31625 colors[ind].b = si[2];
31626 set_bit(colors_used, ind, true);
31627 si += 3;
31628 }
31629 }
31630
31631 //Loads a cset to paldata from the main palette
31632 void user_paldata::load_cset_main(int32_t cset)
31633 {
31634 for (int32_t q = 0; q < 16; ++q)
31635 {
31636 int32_t ind = CSET(cset) + q;
31637 colors[ind].r = RAMpal[ind].r;
31638 colors[ind].g = RAMpal[ind].g;
31639 colors[ind].b = RAMpal[ind].b;
31640 set_bit(colors_used, ind, true);
31641 }
31642 }
31643
31644 //Writes to a memory cset from paldata
31645 void user_paldata::write_cset(int32_t cset, int32_t dataset)
31646 {
31647 byte* si = colordata + CSET(dataset) * 3;
31648 for (int32_t q = 0; q < 16; ++q)
31649 {
31650 int32_t ind = CSET(cset) + q;
31651 if (get_bit(colors_used, ind))
31652 {
31653 si[0] = colors[ind].r;
31654 si[1] = colors[ind].g;
31655 si[2] = colors[ind].b;
31656 }
31657 si += 3;
31658 }
31659 }
31660
31661 //Writes to a main palette cset from paldata
31662 void user_paldata::write_cset_main(int32_t cset)
31663 {
31664 for (int32_t q = 0; q < 16; ++q)
31665 {
31666 int32_t ind = CSET(cset) + q;
31667 if (get_bit(colors_used, ind))
31668 {
31669 RAMpal[ind] = colors[ind];
31670 }
31671 }
31672 }
31673
31674
31675 //Checks a memory cset from
31676
31677
31678
31679
31680 bool user_paldata::check_cset(int32_t cset, int32_t dataset)
31681 {
31682 byte* si = colordata + CSET(dataset) * 3;
31683 for (int32_t q = 0; q < 16; ++q)
31684 {
31685 int32_t ind = CSET(cset) + q;
31686 if (get_bit(colors_used, ind))
31687 {
31688 if (si[0] != colors[ind].r)
31689 return true;
31690 if (si[1] != colors[ind].g)
31691 return true;
31692 if (si[2] != colors[ind].b)
31693 return true;
31694 }
31695 si += 3;
31696 }
31697 return false;
31698 }
31699
31700 //Checks a memory cset from the main palette
31701 bool user_paldata::check_cset_main(int32_t cset)
31702 {
31703 for (int32_t q = 0; q < 16; ++q)
31704 {
31705 int32_t ind = CSET(cset) + q;
31706 if (get_bit(colors_used, ind))
31707 {
31708 if (RAMpal[ind].r != colors[ind].r)
31709 return true;
31710 if (RAMpal[ind].g != colors[ind].g)
31711 return true;
31712 if (RAMpal[ind].b != colors[ind].b)
31713 return true;
31714 }
31715 }
31716 return false;
31717 }
31718
31719 //Mixes a color between two paldatas
31720 RGB user_paldata::mix_color(RGB start, RGB end, double percent, int32_t color_space)
31721 {
31722 int32_t direction = 0;
31723 switch (color_space)
31724 {
31725 case CSPACE_RGB:
31726 return _RGB(byte(vbound(double(zc::math::Lerp(start.r, end.r, percent)), 0.0, 63.0)),
31727 byte(vbound(double(zc::math::Lerp(start.g, end.g, percent)), 0.0, 63.0)),
31728 byte(vbound(double(zc::math::Lerp(start.b, end.b, percent)), 0.0, 63.0)));
31729 case CSPACE_CMYK:
31730 {
31731 double convert_start[4];
31732 double convert_end[4];
31733 double convert_result[4];
31734 RGBTo(start, convert_start, color_space);
31735 RGBTo(end, convert_end, color_space);
31736 convert_result[0] = zc::math::Lerp(convert_start[0], convert_end[0], percent);
31737 convert_result[1] = zc::math::Lerp(convert_start[1], convert_end[1], percent);
31738 convert_result[2] = zc::math::Lerp(convert_start[2], convert_end[2], percent);
31739 convert_result[3] = zc::math::Lerp(convert_start[3], convert_end[3], percent);
31740 return RGBFrom(convert_result, color_space);
31741 }
31742 case CSPACE_HSV_CW:
31743 if (color_space == CSPACE_HSV_CW)
31744 direction = 1;
31745 [[fallthrough]];
31746 case CSPACE_HSV_CCW:
31747 if (color_space == CSPACE_HSV_CCW)
31748 direction = -1;
31749 [[fallthrough]];
31750 case CSPACE_HSV:
31751 {
31752 double convert_start[3];
31753 double convert_end[3];
31754 double convert_result[3];
31755 RGBTo(start, convert_start, color_space);
31756 RGBTo(end, convert_end, color_space);
31757 convert_result[0] = WrapLerp(convert_start[0], convert_end[0], percent, 0.0, 1.0, direction);
31758 convert_result[1] = zc::math::Lerp(convert_start[1], convert_end[1], percent);
31759 convert_result[2] = zc::math::Lerp(convert_start[2], convert_end[2], percent);
31760 return RGBFrom(convert_result, color_space);
31761 }
31762 case CSPACE_HSL_CW:
31763 if (color_space == CSPACE_HSL_CW)
31764 direction = 1;
31765 [[fallthrough]];
31766 case CSPACE_HSL_CCW:
31767 if (color_space == CSPACE_HSL_CCW)
31768 direction = -1;
31769 [[fallthrough]];
31770 case CSPACE_HSL:
31771 {
31772 double convert_start[3];
31773 double convert_end[3];
31774 double convert_result[3];
31775 RGBTo(start, convert_start, color_space);
31776 RGBTo(end, convert_end, color_space);
31777 convert_result[0] = WrapLerp(convert_start[0], convert_end[0], percent, 0.0, 1.0, direction);
31778 convert_result[1] = zc::math::Lerp(convert_start[1], convert_end[1], percent);
31779 convert_result[2] = zc::math::Lerp(convert_start[2], convert_end[2], percent);
31780 return RGBFrom(convert_result, color_space);
31781 }
31782 case CSPACE_LAB:
31783 {
31784 double convert_start[3];
31785 double convert_end[3];
31786 double convert_result[3];
31787 RGBTo(start, convert_start, color_space);
31788 RGBTo(end, convert_end, color_space);
31789 convert_result[0] = zc::math::Lerp(convert_start[0], convert_end[0], percent);
31790 convert_result[1] = zc::math::Lerp(convert_start[1], convert_end[1], percent);
31791 convert_result[2] = zc::math::Lerp(convert_start[2], convert_end[2], percent);
31792 return RGBFrom(convert_result, color_space);
31793 }
31794 case CSPACE_LCH_CW:
31795 if (color_space == CSPACE_LCH_CW)
31796 direction = 1;
31797 [[fallthrough]];
31798 case CSPACE_LCH_CCW:
31799 if (color_space == CSPACE_LCH_CCW)
31800 direction = -1;
31801 [[fallthrough]];
31802 case CSPACE_LCH:
31803 {
31804 double convert_start[3];
31805 double convert_end[3];
31806 double convert_result[3];
31807 RGBTo(start, convert_start, color_space);
31808 RGBTo(end, convert_end, color_space);
31809 convert_result[0] = zc::math::Lerp(convert_start[0], convert_end[0], percent);
31810 convert_result[1] = zc::math::Lerp(convert_start[1], convert_end[1], percent);
31811 convert_result[2] = WrapLerp(convert_start[2], convert_end[2], percent, 0.0, 360.0, direction);
31812 return RGBFrom(convert_result, color_space);
31813 }
31814 }
31815 return start;
31816 }
31817
31818 void user_paldata::RGBTo(RGB c, double arr[], int32_t color_space)
31819 {
31820 //From easyrgb.com/en/math.php
31821 double r = vbound(c.r / 63.0, 0.0, 1.0);
31822 double g = vbound(c.g / 63.0, 0.0, 1.0);
31823 double b = vbound(c.b / 63.0, 0.0, 1.0);
31824 switch (color_space)
31825 {
31826 case CSPACE_CMYK:
31827 {
31828 double c = 1.0 - r;
31829 double m = 1.0 - g;
31830 double y = 1.0 - b;
31831
31832 double k = 1.0;
31833
31834 if (c < k) k = c;
31835 if (m < k) k = m;
31836 if (y < k) k = y;
31837 if (k == 1)
31838 {
31839 c = 0.0;
31840 m = 0.0;
31841 y = 0.0;
31842 }
31843 else
31844 {
31845 c = (c - k) / (1.0 - k);
31846 m = (m - k) / (1.0 - k);
31847 y = (y - k) / (1.0 - k);
31848 }
31849 arr[0] = c;
31850 arr[1] = m;
31851 arr[2] = y;
31852 arr[3] = k;
31853 break;
31854 }
31855 case CSPACE_HSV_CW:
31856 case CSPACE_HSV_CCW:
31857 case CSPACE_HSV:
31858 {
31859 double min_val = std::min(std::min(r, g), b);
31860 double max_val = std::max(std::max(r, g), b);
31861 double del_max = max_val - min_val;
31862
31863 double h = 0;
31864 double s = 0;
31865 double v = max_val;
31866
31867 if (del_max != 0) //Set chroma if not gray
31868 {
31869 s = del_max / max_val;
31870
31871 double del_r = (((max_val - r) / 6.0) + (del_max / 2.0)) / del_max;
31872 double del_g = (((max_val - g) / 6.0) + (del_max / 2.0)) / del_max;
31873 double del_b = (((max_val - b) / 6.0) + (del_max / 2.0)) / del_max;
31874
31875 if (r == max_val) h = del_b - del_g;
31876 else if (g == max_val) h = (1.0 / 3.0) + del_r - del_b;
31877 else if (b == max_val) h = (2.0 / 3.0) + del_g - del_r;
31878
31879 if (h < 0) ++h;
31880 if (h > 1) --h;
31881 }
31882
31883 arr[0] = h;
31884 arr[1] = s;
31885 arr[2] = v;
31886 break;
31887 }
31888 case CSPACE_HSL_CW:
31889 case CSPACE_HSL_CCW:
31890 case CSPACE_HSL:
31891 {
31892 double min_val = std::min(std::min(r, g), b);
31893 double max_val = std::max(std::max(r, g), b);
31894 double del_max = max_val - min_val;
31895
31896 double h = 0;
31897 double s = 0;
31898 double l = (max_val + min_val) / 2.0;
31899
31900 if (del_max != 0) //Set chroma if not gray
31901 {
31902 if (l < 0.5) s = del_max / (max_val + min_val);
31903 else s = del_max / (2 - max_val - min_val);
31904
31905 double del_r = (((max_val - r) / 6.0) + (del_max / 2.0)) / del_max;
31906 double del_g = (((max_val - g) / 6.0) + (del_max / 2.0)) / del_max;
31907 double del_b = (((max_val - b) / 6.0) + (del_max / 2.0)) / del_max;
31908
31909 if (r == max_val) h = del_b - del_g;
31910 else if (g == max_val) h = (1.0 / 3.0) + del_r - del_b;
31911 else if (b == max_val) h = (2.0 / 3.0) + del_g - del_r;
31912
31913 if (h < 0) ++h;
31914 if (h > 1) --h;
31915 }
31916
31917 arr[0] = h;
31918 arr[1] = s;
31919 arr[2] = l;
31920 break;
31921 }
31922 case CSPACE_LAB:
31923 {
31924 if (r > 0.04045) r = pow(((r + 0.055) / 1.055), 2.4);
31925 else r /= 12.92;
31926 if (g > 0.04045) g = pow(((g + 0.055) / 1.055), 2.4);
31927 else g /= 12.92;
31928 if (b > 0.04045) b = pow(((b + 0.055) / 1.055), 2.4);
31929 else b /= 12.92;
31930
31931 double x = r * 0.4124 + g * 0.3576 + b * 0.1805;
31932 double y = r * 0.2126 + g * 0.7152 + b * 0.0722;
31933 double z = r * 0.0193 + g * 0.1192 + b * 0.9505;
31934
31935 if (x > 0.008856) x = pow(x, 1.0 / 3.0);
31936 else x = (7.787 * x) + (16.0 / 116.0);
31937 if (y > 0.008856) y = pow(y, 1.0 / 3.0);
31938 else y = (7.787 * y) + (16.0 / 116.0);
31939 if (z > 0.008856) z = pow(z, 1.0 / 3.0);
31940 else z = (7.787 * z) + (16.0 / 116.0);
31941
31942 double CIEL = (116 * y) - 16;
31943 double CIEa = 500 * (x - y);
31944 double CIEb = 200 * (y - z);
31945
31946 arr[0] = CIEL;
31947 arr[1] = CIEa;
31948 arr[2] = CIEb;
31949 break;
31950 }
31951 case CSPACE_LCH_CW:
31952 case CSPACE_LCH_CCW:
31953 case CSPACE_LCH:
31954 {
31955 if (r > 0.04045) r = pow(((r + 0.055) / 1.055), 2.4);
31956 else r /= 12.92;
31957 if (g > 0.04045) g = pow(((g + 0.055) / 1.055), 2.4);
31958 else g /= 12.92;
31959 if (b > 0.04045) b = pow(((b + 0.055) / 1.055), 2.4);
31960 else b /= 12.92;
31961
31962 double x = r * 0.4124 + g * 0.3576 + b * 0.1805;
31963 double y = r * 0.2126 + g * 0.7152 + b * 0.0722;
31964 double z = r * 0.0193 + g * 0.1192 + b * 0.9505;
31965
31966 if (x > 0.008856) x = pow(x, 1.0 / 3.0);
31967 else x = (7.787 * x) + (16.0 / 116.0);
31968 if (y > 0.008856) y = pow(y, 1.0 / 3.0);
31969 else y = (7.787 * y) + (16.0 / 116.0);
31970 if (z > 0.008856) z = pow(z, 1.0 / 3.0);
31971 else z = (7.787 * z) + (16.0 / 116.0);
31972
31973 double CIEL = (116 * y) - 16;
31974 double CIEa = 500 * (x - y);
31975 double CIEb = 200 * (y - z);
31976
31977 double h = atan2(CIEb, CIEa);
31978 if (h > 0) h = (h / PI) * 180;
31979 else h = 360 - (abs(h) / PI) * 180;
31980
31981 double CIEC = sqrt(pow(CIEa, 2) + pow(CIEb, 2));
31982
31983 arr[0] = CIEL;
31984 arr[1] = CIEC;
31985 arr[2] = h;
31986 break;
31987 }
31988 }
31989
31990 }
31991
31992 RGB user_paldata::RGBFrom(double arr[], int32_t color_space)
31993 {
31994 double r = 0.0;
31995 double g = 0.0;
31996 double b = 0.0;
31997 switch (color_space)
31998 {
31999 case CSPACE_CMYK:
32000 {
32001 double c = (arr[0] * (1 - arr[3]) + arr[3]);
32002 double m = (arr[1] * (1 - arr[3]) + arr[3]);
32003 double y = (arr[2] * (1 - arr[3]) + arr[3]);
32004
32005 r = vbound((1 - c) * 63.0, 0.0, 63.0);
32006 g = vbound((1 - m) * 63.0, 0.0, 63.0);
32007 b = vbound((1 - y) * 63.0, 0.0, 63.0);
32008 return _RGB(r, g, b);
32009 break;
32010 }
32011 case CSPACE_HSV_CW:
32012 case CSPACE_HSV_CCW:
32013 case CSPACE_HSV:
32014 {
32015 double h = arr[0];
32016 double s = arr[1];
32017 double v = arr[2];
32018
32019 if (s == 0)
32020 {
32021 r = v;
32022 g = v;
32023 b = v;
32024 }
32025 else
32026 {
32027 double var_h = h * 6;
32028 if (var_h >= 6) var_h = 0;
32029 int32_t var_i = floor(var_h);
32030 double var_1 = v * (1 - s);
32031 double var_2 = v * (1 - s * (var_h - var_i));
32032 double var_3 = v * (1 - s * (1 - (var_h - var_i)));
32033
32034 switch (var_i)
32035 {
32036 case 0:
32037 r = v;
32038 g = var_3;
32039 b = var_1;
32040 break;
32041 case 1:
32042 r = var_2;
32043 g = v;
32044 b = var_1;
32045 break;
32046 case 2:
32047 r = var_1;
32048 g = v;
32049 b = var_3;
32050 break;
32051 case 3:
32052 r = var_1;
32053 g = var_2;
32054 b = v;
32055 break;
32056 case 4:
32057 r = var_3;
32058 g = var_1;
32059 b = v;
32060 break;
32061 default:
32062 r = v;
32063 g = var_1;
32064 b = var_2;
32065 }
32066 }
32067
32068 r = vbound(r * 63.0, 0.0, 63.0);
32069 g = vbound(g * 63.0, 0.0, 63.0);
32070 b = vbound(b * 63.0, 0.0, 63.0);
32071
32072 return _RGB(r, g, b);
32073 }
32074 case CSPACE_HSL_CW:
32075 case CSPACE_HSL_CCW:
32076 case CSPACE_HSL:
32077 {
32078 double h = arr[0];
32079 double s = arr[1];
32080 double l = arr[2];
32081
32082 if (s == 0)
32083 {
32084 r = l;
32085 g = l;
32086 b = l;
32087 }
32088 else
32089 {
32090 double var_1;
32091 double var_2;
32092 if (l < 0.5)var_2 = l * (1 + s);
32093 else var_2 = (l + s) - (s * l);
32094
32095 var_1 = 2 * l - var_2;
32096
32097 r = HueToRGB(var_1, var_2, h + (1.0 / 3.0));
32098 g = HueToRGB(var_1, var_2, h);
32099 b = HueToRGB(var_1, var_2, h - (1.0 / 3.0));
32100 }
32101
32102 r = vbound(r * 63.0, 0.0, 63.0);
32103 g = vbound(g * 63.0, 0.0, 63.0);
32104 b = vbound(b * 63.0, 0.0, 63.0);
32105
32106 return _RGB(r, g, b);
32107 }
32108 case CSPACE_LAB:
32109 {
32110 double CIEL = arr[0];
32111 double CIEa = arr[1];
32112 double CIEb = arr[2];
32113
32114 double var_y = (CIEL + 16) / 116.0;
32115 double var_x = CIEa / 500.0 + var_y;
32116 double var_z = var_y - CIEb / 200.0;
32117
32118 if (pow(var_x, 3) > 0.008856) var_x = pow(var_x, 3);
32119 else var_x = (var_x - 16.0 / 116.0) / 7.787;
32120 if (pow(var_y, 3) > 0.008856) var_y = pow(var_y, 3);
32121 else var_y = (var_y - 16.0 / 116.0) / 7.787;
32122 if (pow(var_z, 3) > 0.008856) var_z = pow(var_z, 3);
32123 else var_z = (var_z - 16.0 / 116.0) / 7.787;
32124
32125 r = var_x * 3.2406 + var_y * -1.5372 + var_z * -0.4986;
32126 g = var_x * -0.9689 + var_y * 1.8758 + var_z * 0.0415;
32127 b = var_x * 0.0557 + var_y * -0.2040 + var_z * 1.0570;
32128
32129 if (r > 0.0031308) r = 1.055 * pow(r, (1 / 2.4)) - 0.055;
32130 else r = 12.92 * r;
32131 if (g > 0.0031308) g = 1.055 * pow(g, (1 / 2.4)) - 0.055;
32132 else g = 12.92 * g;
32133 if (b > 0.0031308) b = 1.055 * pow(b, (1 / 2.4)) - 0.055;
32134 else b = 12.92 * b;
32135
32136 r = vbound(r * 63.0, 0.0, 63.0);
32137 g = vbound(g * 63.0, 0.0, 63.0);
32138 b = vbound(b * 63.0, 0.0, 63.0);
32139
32140 return _RGB(r, g, b);
32141 }
32142 case CSPACE_LCH_CW:
32143 case CSPACE_LCH_CCW:
32144 case CSPACE_LCH:
32145 {
32146 double CIEL = arr[0];
32147 double CIEa = cos((arr[2] * PI) / 180.0) * arr[1];
32148 double CIEb = sin((arr[2] * PI) / 180.0) * arr[1];
32149
32150 double var_y = (CIEL + 16) / 116.0;
32151 double var_x = CIEa / 500.0 + var_y;
32152 double var_z = var_y - CIEb / 200.0;
32153
32154 if (pow(var_y, 3) > 0.008856) var_y = pow(var_y, 3);
32155 else var_y = (var_y - 16.0 / 116.0) / 7.787;
32156 if (pow(var_x, 3) > 0.008856) var_x = pow(var_x, 3);
32157 else var_x = (var_x - 16.0 / 116.0) / 7.787;
32158 if (pow(var_z, 3) > 0.008856) var_z = pow(var_z, 3);
32159 else var_z = (var_z - 16.0 / 116.0) / 7.787;
32160
32161 r = var_x * 3.2406 + var_y * -1.5372 + var_z * -0.4986;
32162 g = var_x * -0.9689 + var_y * 1.8758 + var_z * 0.0415;
32163 b = var_x * 0.0557 + var_y * -0.2040 + var_z * 1.0570;
32164
32165 if (r > 0.0031308) r = 1.055 * pow(r, (1 / 2.4)) - 0.055;
32166 else r = 12.92 * r;
32167 if (g > 0.0031308) g = 1.055 * pow(g, (1 / 2.4)) - 0.055;
32168 else g = 12.92 * g;
32169 if (b > 0.0031308) b = 1.055 * pow(b, (1 / 2.4)) - 0.055;
32170 else b = 12.92 * b;
32171
32172 r = vbound(r * 63.0, 0.0, 63.0);
32173 g = vbound(g * 63.0, 0.0, 63.0);
32174 b = vbound(b * 63.0, 0.0, 63.0);
32175
32176 return _RGB(r, g, b);
32177 }
32178 }
32179 return _RGB(0, 0, 0);
32180 }
32181 double user_paldata::HueToRGB(double v1, double v2, double vH)
32182 {
32183 if (vH < 0) vH += 1;
32184 if (vH > 1) vH -= 1;
32185 if ((6 * vH) < 1) return (v1 + (v2 - v1) * 6 * vH);
32186 if ((2 * vH) < 1) return (v2);
32187 if ((3 * vH) < 2) return (v1 + (v2 - v1) * ((2.0 / 3.0) - vH) * 6);
32188 return (v1);
32189 }
32190
32191 double user_paldata::WrapLerp(double a, double b, double t, double min, double max, int32_t direction)
32192 {
32193 double dif = abs(a - b);
32194 double range = abs(max - min);
32195
32196 switch (direction)
32197 {
32198 case 0:
32199 if (dif > range * 0.5)
32200 dif = range - dif;
32201 if (a + dif == b)
32202 direction = 1;
32203 else
32204 direction = -1;
32205 break;
32206 case 1:
32207 if (b < a)
32208 dif = range - dif;
32209 break;
32210 case -1:
32211 if (b > a)
32212 dif = range - dif;
32213 break;
32214 }
32215
32216 double ret = zc::math::Lerp(a, a + dif * direction, t);
32217
32218 if (ret <= min)
32219 ret += range;
32220 else if (ret >= max)
32221 ret -= range;
32222 return ret;
32223 }
32224
32225 //Mixes an entire palette given two paldatas
32226 void user_paldata::mix(user_paldata *pal_start, user_paldata *pal_end, double percent, int32_t color_space, int32_t start_color, int32_t end_color)
32227 {
32228 for (int32_t q = start_color; q < end_color; ++q)
32229 {
32230 if (get_bit(pal_start->colors_used, q) && get_bit(pal_end->colors_used, q)) {
32231 RGB start = pal_start->colors[q];
32232 RGB end = pal_end->colors[q];
32233 colors[q] = mix_color(start, end, percent, color_space);
32234 set_bit(colors_used, q, true);
32235 }
32236 }
32237 }
32238
32239 void item_display_name(const bool setter)
32240 {
32241 int32_t ID = ri->idata;
32242 if(unsigned(ID) >= MAXITEMS)
32243 return;
32244 int32_t arrayptr = get_register(sarg1) / 10000;
32245 if(setter)
32246 {
32247 std::string str;
32248 ArrayH::getString(arrayptr, str, 255);
32249 strcpy(itemsbuf[ID].display_name, str.c_str());
32250 }
32251 else
32252 {
32253 if(ArrayH::setArray(arrayptr, string(itemsbuf[ID].display_name)) == SH::_Overflow)
32254 Z_scripterrlog("Array supplied to 'itemdata->GetDisplayName()' not large enough\n");
32255 }
32256 }
32257 void item_shown_name()
32258 {
32259 int32_t ID = ri->idata;
32260 if(unsigned(ID) >= MAXITEMS)
32261 return;
32262 int32_t arrayptr = get_register(sarg1) / 10000;
32263 if(ArrayH::setArray(arrayptr, itemsbuf[ID].get_name()) == SH::_Overflow)
32264 Z_scripterrlog("Array supplied to 'itemdata->GetShownName()' not large enough\n");
32265 }
32266
32267 void FFScript::do_getDMapData_dmapname(const bool v)
32268 {
32269 //int32_t ID = ri->zmsgref;
32270 int32_t ID = ri->dmapsref;
32271 int32_t arrayptr = get_register(sarg1) / 10000;
32272
32273 if(BC::checkDMapID(ID, "dmapdata->GetName()") != SH::_NoError)
32274 return;
32275
32276 if(ArrayH::setArray(arrayptr, string(DMaps[ID].name)) == SH::_Overflow)
32277 Z_scripterrlog("Array supplied to 'dmapdata->GetName()' not large enough\n");
32278 }
32279
32280 void FFScript::do_setDMapData_dmapname(const bool v)
32281 {
32282 //int32_t ID = ri->zmsgref;
32283 int32_t ID = ri->dmapsref;
32284 int32_t arrayptr = get_register(sarg1) / 10000;
32285
32286 string filename_str;
32287
32288 if(BC::checkDMapID(ID, "dmapdata->SetName()") != SH::_NoError)
32289 return;
32290
32291
32292 ArrayH::getString(arrayptr, filename_str, 22);
32293 strncpy(DMaps[ID].name, filename_str.c_str(), 21);
32294 DMaps[ID].name[20]='\0';
32295 }
32296
32297 void FFScript::do_getDMapData_dmaptitle(const bool v)
32298 {
32299 //int32_t ID = ri->zmsgref;
32300 int32_t ID = ri->dmapsref;
32301 int32_t arrayptr = get_register(sarg1) / 10000;
32302
32303 if(BC::checkDMapID(ID, "dmapdata->GetTitle()") != SH::_NoError)
32304 return;
32305
32306 if (!get_qr(qr_OLD_DMAP_INTRO_STRINGS))
32307 {
32308 ArrayManager am(arrayptr);
32309 am.resize(DMaps[ID].title.size() + 1);
32310 }
32311 if(ArrayH::setArray(arrayptr, string(DMaps[ID].title)) == SH::_Overflow)
32312 Z_scripterrlog("Array supplied to 'dmapdata->GetTitle()' not large enough\n");
32313 }
32314
32315 void FFScript::do_setDMapData_dmaptitle(const bool v)
32316 {
32317 //int32_t ID = ri->zmsgref;
32318 int32_t ID = ri->dmapsref;
32319 int32_t arrayptr = get_register(sarg1) / 10000;
32320 string filename_str;
32321
32322 if(BC::checkDMapID(ID, "dmapdata->SetTitle()") != SH::_NoError)
32323 return;
32324
32325 if (get_qr(qr_OLD_DMAP_INTRO_STRINGS))
32326 {
32327 char namestr[21];
32328 ArrayH::getString(arrayptr, filename_str, 21);
32329 strncpy(namestr, filename_str.c_str(), 20);
32330 namestr[20] = '\0';
32331 DMaps[ID].title.assign(namestr);
32332 }
32333 else
32334 {
32335 ArrayH::getString(arrayptr, filename_str, ArrayH::getSize(arrayptr));
32336 DMaps[ID].title = filename_str;
32337 }
32338 }
32339
32340 void FFScript::do_getDMapData_dmapintro(const bool v)
32341 {
32342 //int32_t ID = ri->zmsgref;
32343 int32_t ID = ri->dmapsref;
32344 int32_t arrayptr = get_register(sarg1) / 10000;
32345
32346 if(BC::checkDMapID(ID, "dmapdata->GetIntro()") != SH::_NoError)
32347 return;
32348
32349 if(ArrayH::setArray(arrayptr, string(DMaps[ID].intro)) == SH::_Overflow)
32350 Z_scripterrlog("Array supplied to 'dmapdata->GetIntro()' not large enough\n");
32351 }
32352
32353 void FFScript::do_setDMapData_dmapintro(const bool v)
32354 {
32355 //int32_t ID = ri->zmsgref;
32356 int32_t ID = ri->dmapsref;
32357 int32_t arrayptr = get_register(sarg1) / 10000;
32358 string filename_str;
32359
32360 if(BC::checkDMapID(ID, "dmapdata->SetIntro()") != SH::_NoError)
32361 return;
32362
32363
32364 ArrayH::getString(arrayptr, filename_str, 73);
32365 strncpy(DMaps[ID].intro, filename_str.c_str(), 72);
32366 DMaps[ID].intro[72]='\0';
32367 }
32368
32369 void FFScript::do_getDMapData_music(const bool v)
32370 {
32371 //int32_t ID = ri->zmsgref;
32372 int32_t ID = ri->dmapsref;
32373 int32_t arrayptr = get_register(sarg1) / 10000;
32374
32375 if(BC::checkDMapID(ID, "dmapdata->GetMusic()") != SH::_NoError)
32376 return;
32377
32378 if(ArrayH::setArray(arrayptr, string(DMaps[ID].tmusic)) == SH::_Overflow)
32379 Z_scripterrlog("Array supplied to 'dmapdata->GetMusic()' not large enough\n");
32380 }
32381
32382 void FFScript::do_setDMapData_music(const bool v)
32383 {
32384 //int32_t ID = ri->zmsgref;
32385 int32_t ID = ri->dmapsref;
32386 int32_t arrayptr = get_register(sarg1) / 10000;
32387 string filename_str;
32388
32389 if(BC::checkDMapID(ID, "dmapdata->SetMusic()") != SH::_NoError)
32390 return;
32391
32392
32393 ArrayH::getString(arrayptr, filename_str, 56);
32394 strncpy(DMaps[ID].tmusic, filename_str.c_str(), 55);
32395 DMaps[ID].tmusic[55]='\0';
32396 }
32397
32398 void FFScript::do_loadnpcdata(const bool v)
32399 {
32400 int32_t ID = SH::get_arg(sarg1, v) / 10000;
32401
32402 if ( ID < 1 || ID > (MAXGUYS-1) )
32403 {
32404 Z_scripterrlog("Invalid NPC ID passed to Game->LoadNPCData: %d\n", ID);
32405 ri->npcdataref = MAX_DWORD;
32406 }
32407
32408 else ri->npcdataref = ID;
32409 //Z_eventlog("Script loaded npcdata with ID = %ld\n", ri->idata);
32410 }
32411 void FFScript::do_loadmessagedata(const bool v)
32412 {
32413 int32_t ID = SH::get_arg(sarg1, v) / 10000;
32414
32415 if ( ID < 1 || ID > (msg_count-1) )
32416 {
32417 Z_scripterrlog("Invalid Message ID passed to Game->LoadMessageData: %d\n", ID);
32418 ri->zmsgref = MAX_DWORD;
32419 }
32420
32421 else ri->zmsgref = ID;
32422 //Z_eventlog("Script loaded npcdata with ID = %ld\n", ri->idata);
32423 }
32424 //same syntax as loadmessage data
32425 //the input is an array
32426 void FFScript::do_messagedata_setstring(const bool v)
32427 {
32428 int32_t arrayptr = get_register(sarg1) / 10000;
32429 int32_t ID = ri->zmsgref;
32430 if(BC::checkMessage(ID, "messagesata->Set()") != SH::_NoError)
32431 return;
32432
32433 ArrayH::getString(arrayptr, MsgStrings[ID].s, MSG_NEW_SIZE);
32434 }
32435 void FFScript::do_messagedata_getstring(const bool v)
32436 {
32437 int32_t ID = ri->zmsgref;
32438 int32_t arrayptr = get_register(sarg1) / 10000;
32439
32440 if(BC::checkMessage(ID, "messagedata->Get()") != SH::_NoError)
32441 return;
32442
32443 if(ArrayH::setArray(arrayptr, MsgStrings[ID].s) == SH::_Overflow)
32444 Z_scripterrlog("Array supplied to 'messagedata->Get()' not large enough\n");
32445 }
32446
32447 25412 void FFScript::do_loadcombodata(const bool v)
32448 {
32449 25412 int32_t ID = SH::get_arg(sarg1, v) / 10000;
32450
32451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25412 times.
25412 if ( (unsigned)ID > (MAXCOMBOS-1) )
32452 {
32453 Z_scripterrlog("Invalid Combo ID passed to Game->LoadComboData: %d\n", ID);
32454 ri->combosref = 0;
32455 }
32456
32457 25412 else ri->combosref = ID;
32458 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
32459 25412 }
32460
32461 void FFScript::do_loadmapdata(const bool v)
32462 {
32463 int32_t _map = SH::get_arg(sarg1, v) / 10000;
32464
32465 int32_t _scr = SH::get_arg(sarg2, v) / 10000;
32466 // zprint("LoadMapData Map Value: %d\n", _map);
32467 // zprint("LoadMapData Screen Value: %d\n", _scr);
32468 int32_t indx = (_map * MAPSCRS + _scr);
32469 // zprint("LoadMapData Indx Value: %d\n", indx);
32470 if ( _map < 1 || _map > (map_count-1) )
32471 {
32472 Z_scripterrlog("Invalid Map ID passed to Game->LoadMapData: %d\n", _map);
32473 ri->mapsref = 0;
32474 }
32475 else if ( (unsigned)_scr > 129 ) //0x00 to 0x81 -Z
32476 {
32477 Z_scripterrlog("Invalid Screen ID passed to Game->LoadMapData: %d\n", _scr);
32478 ri->mapsref = 0;
32479 }
32480 else ri->mapsref = indx;
32481 // zprint("LoadMapData Screen set ri->mapsref to: %d\n", ri->mapsref);
32482 //zprint("Script loaded mapdata with ID = %ld\n", ri->idata);
32483 }
32484
32485 403560 void FFScript::do_loadmapdata_tempscr(const bool v)
32486 {
32487 403560 int32_t layer = SH::get_arg(sarg1, v) / 10000;
32488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 403560 times.
403560 if(BC::checkBounds(layer, 0, 6, "Game->LoadTempScreen()") != SH::_NoError)
32489 {
32490 ri->mapsref = 0;
32491 return;
32492 }
32493
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 89786 times.
✓ Branch 2 taken 118175 times.
✓ Branch 3 taken 103000 times.
✓ Branch 4 taken 915 times.
✓ Branch 5 taken 91682 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
403560 switch(layer)
32494 {
32495 89786 case 0: ri->mapsref = MAPSCR_TEMP0; break;
32496 118175 case 1: ri->mapsref = MAPSCR_TEMP1; break;
32497 103000 case 2: ri->mapsref = MAPSCR_TEMP2; break;
32498 915 case 3: ri->mapsref = MAPSCR_TEMP3; break;
32499 91682 case 4: ri->mapsref = MAPSCR_TEMP4; break;
32500 1 case 5: ri->mapsref = MAPSCR_TEMP5; break;
32501 1 case 6: ri->mapsref = MAPSCR_TEMP6; break;
32502 }
32503 403560 set_register(sarg1, ri->mapsref);
32504 403560 }
32505
32506 177544 void FFScript::do_loadmapdata_scrollscr(const bool v)
32507 {
32508 177544 int32_t layer = SH::get_arg(sarg1, v) / 10000;
32509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177544 times.
177544 if(BC::checkBounds(layer, 0, 6, "Game->LoadScrollingScreen()") != SH::_NoError)
32510 {
32511 ri->mapsref = 0;
32512 return;
32513 }
32514
3/8
✗ Branch 0 not taken.
✓ Branch 1 taken 88755 times.
✓ Branch 2 taken 88755 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 34 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
177544 switch(layer)
32515 {
32516 88755 case 0: ri->mapsref = MAPSCR_SCROLL0; break;
32517 88755 case 1: ri->mapsref = MAPSCR_SCROLL1; break;
32518 case 2: ri->mapsref = MAPSCR_SCROLL2; break;
32519 case 3: ri->mapsref = MAPSCR_SCROLL3; break;
32520 34 case 4: ri->mapsref = MAPSCR_SCROLL4; break;
32521 case 5: ri->mapsref = MAPSCR_SCROLL5; break;
32522 case 6: ri->mapsref = MAPSCR_SCROLL6; break;
32523 }
32524 177544 set_register(sarg1, ri->mapsref);
32525 177544 }
32526
32527 void FFScript::do_loadshopdata(const bool v)
32528 {
32529 int32_t ID = SH::get_arg(sarg1, v) / 10000;
32530
32531 if ( (unsigned)ID > 255 )
32532 {
32533 Z_scripterrlog("Invalid Shop ID passed to Game->LoadShopData: %d\n", ID);
32534 ri->shopsref = 0;
32535 }
32536 else ri->shopsref = ID;
32537 //Z_eventlog("Script loaded npcdata with ID = %ld\n", ri->idata);
32538 }
32539
32540
32541 void FFScript::do_loadinfoshopdata(const bool v)
32542 {
32543 int32_t ID = SH::get_arg(sarg1, v) / 10000;
32544
32545 if ( (unsigned)ID > 255 )
32546 {
32547 Z_scripterrlog("Invalid Shop ID passed to Game->LoadShopData: %d\n", ID);
32548 ri->shopsref = 0;
32549 }
32550 else ri->shopsref = ID+NUMSHOPS;
32551 //Z_eventlog("Script loaded npcdata with ID = %ld\n", ri->idata);
32552 }
32553
32554 /*
32555 void FFScript::do_loadmapdata(const bool v)
32556 {
32557 int32_t ID = SH::get_arg(sarg1, v) / 10000;
32558
32559 if ( ID < 0 || ID > (map_count-1) )
32560 {
32561 Z_scripterrlog("Invalid Map ID passed to Game->LoadMapData: %d\n", ID);
32562 ri->mapsref = MAX_SIGNED_32;
32563 }
32564
32565 else ri->mapsref = ID;
32566 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
32567 }
32568 */
32569
32570 /*
32571
32572 void FFScript::do_loadmapdata(const bool v)
32573 {
32574 int32_t ID = get_register(sarg2) / 10000;
32575
32576 if ( ID < 0 || ID > (map_count-1) )
32577 {
32578 Z_scripterrlog("Invalid Map ID passed to Game->LoadMapData: %d\n", ID);
32579 return;
32580 }
32581
32582 ri->mapsref = ID;
32583 set_register(sarg1, ri->mapsref);
32584 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
32585 }
32586
32587 */
32588
32589 16 void FFScript::do_loadspritedata(const bool v)
32590 {
32591 16 int32_t ID = SH::get_arg(sarg1, v) / 10000;
32592
32593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( (unsigned)ID > (MAXWPNS-1) )
32594 {
32595 Z_scripterrlog("Invalid Sprite ID passed to Game->LoadSpriteData: %d\n", ID);
32596 ri->spritesref = 0;
32597 }
32598
32599 16 else ri->spritesref = ID;
32600 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
32601 16 }
32602
32603
32604 void FFScript::do_loadscreendata(const bool v)
32605 {
32606 int32_t ID = SH::get_arg(sarg1, v) / 10000;
32607
32608 if ( (unsigned)ID > (MAXSCREENS-1) )
32609 {
32610 Z_scripterrlog("Invalid Map ID passed to Game->LoadScreenData: %d\n", ID);
32611 ri->screenref = 0;
32612 }
32613
32614 else ri->screenref = ID;
32615 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
32616 }
32617
32618 void FFScript::do_loadbitmapid(const bool v)
32619 {
32620 int32_t ID = SH::get_arg(sarg1, v) / 10000;
32621 switch(ID)
32622 {
32623 case -1:
32624 case 0:
32625 case 1:
32626 case 2:
32627 case 3:
32628 case 4:
32629 case 5:
32630 case 6:
32631 ri->bitmapref = ID+10; break;
32632 default:
32633 {
32634 Z_scripterrlog("Invalid Bitmap ID passed to Game->Load BitmapID: %d\n", ID);
32635 ri->bitmapref = 0; break;
32636 }
32637 }
32638
32639 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
32640 }
32641
32642 77278 void do_createlweapon(const bool v)
32643 {
32644 77278 const int32_t ID = SH::get_arg(sarg1, v) / 10000;
32645
32646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77278 times.
77278 if(BC::checkWeaponID(ID, "Screen->CreateLWeapon") != SH::_NoError)
32647 return;
32648
32649
1/2
✓ Branch 0 taken 77278 times.
✗ Branch 1 not taken.
77278 if ( Lwpns.has_space() )
32650 {
32651 77278 Lwpns.add
32652 (
32653
1/2
✓ Branch 0 taken 77278 times.
✗ Branch 1 not taken.
154556 new weapon
32654 (
32655
1/2
✓ Branch 0 taken 77278 times.
✗ Branch 1 not taken.
77278 (zfix)0, /*X*/
32656
1/2
✓ Branch 0 taken 77278 times.
✗ Branch 1 not taken.
77278 (zfix)0, /*Y*/
32657
1/2
✓ Branch 0 taken 77278 times.
✗ Branch 1 not taken.
77278 (zfix)0, /*Z*/
32658 77278 ID, /*id*/
32659 0, /*type*/
32660 0, /*power*/
32661 0, /*dir*/
32662 -1, /*Parentid*/
32663
1/2
✓ Branch 0 taken 77278 times.
✗ Branch 1 not taken.
77278 Hero.getUID(), /*prntid*/
32664 false, /*isdummy*/
32665 1, /*script_gen*/
32666 1, /*islwpn*/
32667 77278 (ID==wWind?1:0) /*special*/
32668 )
32669 );
32670 77278 ri->lwpn = Lwpns.spr(Lwpns.Count() - 1)->getUID();
32671 //Lwpns.spr(Lwpns.Count() - 1)->LOADGFX(0);
32672 //Lwpns.spr(Lwpns.Count() - 1)->ScriptGenerated = 1;
32673 //Lwpns.spr(Lwpns.Count() - 1)->isLWeapon = 1;
32674 77278 weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //last created
32675 //w->LOADGFX(FFCore.getDefWeaponSprite(ID)); //No.
32676 77278 w->ScriptGenerated = 1;
32677 77278 w->isLWeapon = 1;
32678
1/2
✓ Branch 0 taken 77278 times.
✗ Branch 1 not taken.
77278 if(ID == wWind) w->specialinfo = 1;
32679 77278 Z_eventlog("Script created lweapon %ld with UID = %ld\n", ID, ri->lwpn);
32680 77278 }
32681 else
32682 {
32683 //ri->lwpn = MAX_DWORD;
32684 ri->lwpn = 0; // Now NULL
32685 Z_scripterrlog("Couldn't create lweapon %ld, screen lweapon limit reached\n", ID);
32686 }
32687 77278 }
32688
32689 131917 void do_createeweapon(const bool v)
32690 {
32691 131917 const int32_t ID = SH::get_arg(sarg1, v) / 10000;
32692
32693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131917 times.
131917 if(BC::checkWeaponID(ID, "Screen->CreateEWeapon") != SH::_NoError)
32694 return;
32695
32696
1/2
✓ Branch 0 taken 131917 times.
✗ Branch 1 not taken.
131917 if ( Ewpns.has_space() )
32697 {
32698 131917 addEwpn(0, 0, 0, ID, 0, 0, 0, -1,1); //Param 9 marks it as script-generated.
32699 //Ewpns.spr(Ewpns.Count() - 1)->LOADGFX(0);
32700 //Ewpns.spr(Ewpns.Count() - 1)->ScriptGenerated = 1;
32701 //Ewpns.spr(Ewpns.Count() - 1)->isLWeapon = 0;
32702
4/6
✓ Branch 0 taken 122104 times.
✓ Branch 1 taken 9813 times.
✓ Branch 2 taken 122104 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 122104 times.
✗ Branch 5 not taken.
131917 if( ID > wEnemyWeapons || ( ID >= wScript1 && ID <= wScript10) )
32703 {
32704 131917 weapon *w = (weapon*)Ewpns.spr(Ewpns.Count()-1); //last created
32705 //w->LOADGFX(FFCore.getDefWeaponSprite(ID));
32706 131917 w->ScriptGenerated = 1;
32707 131917 w->isLWeapon = 0;
32708 131917 ri->ewpn = Ewpns.spr(Ewpns.Count() - 1)->getUID();
32709 131917 Z_eventlog("Script created eweapon %ld with UID = %ld\n", ID, ri->ewpn);
32710 131917 }
32711 else
32712 {
32713 Z_scripterrlog("Couldn't create eweapon %ld: Invalid ID/Type (%d) specified.\n", ID);
32714 return;
32715 }
32716 131917 }
32717 else
32718 {
32719 ri->ewpn = 0;
32720 Z_scripterrlog("Couldn't create eweapon %ld, screen eweapon limit reached\n", ID);
32721 }
32722 131917 }
32723
32724 21343 void do_createitem(const bool v)
32725 {
32726 21343 const int32_t ID = SH::get_arg(sarg1, v) / 10000;
32727
32728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21343 times.
21343 if(BC::checkItemID(ID, "Screen->CreateItem") != SH::_NoError)
32729 return;
32730
32731
1/2
✓ Branch 0 taken 21343 times.
✗ Branch 1 not taken.
21343 if ( items.has_space() )
32732 {
32733 21343 additem(0, (get_qr(qr_NOITEMOFFSET) ? 1: 0), ID, ipBIGRANGE);
32734 21343 ri->itemref = items.spr(items.Count() - 1)->getUID();
32735 21343 Z_eventlog("Script created item \"%s\" with UID = %ld\n", item_string[ID], ri->itemref);
32736 21343 }
32737 else
32738 {
32739 ri->itemref = 0;
32740 Z_scripterrlog("Couldn't create item \"%s\", screen item limit reached\n", item_string[ID]);
32741 }
32742 /*
32743 if(items.Count() < 1)
32744 {
32745 ri->itemref = MAX_DWORD;
32746 Z_scripterrlog("Couldn't create item \"%s\", screen item limit reached\n", item_string[ID]);
32747 }
32748 else
32749 {
32750 ri->itemref = items.spr(items.Count() - 1)->getUID();
32751 Z_eventlog("Script created item \"%s\" with UID = %ld\n", item_string[ID], ri->itemref);
32752 }
32753 */
32754 21343 }
32755
32756 2363 void do_createnpc(const bool v)
32757 {
32758 2363 const int32_t ID = SH::get_arg(sarg1, v) / 10000;
32759
32760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2363 times.
2363 if(BC::checkGuyID(ID, "Screen->CreateNPC") != SH::_NoError)
32761 return;
32762
32763 //If we make a segmented enemy there'll be more than one sprite created
32764 2363 word numcreated = addenemy(0, 0, ID, -10);
32765
32766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2363 times.
2363 if(numcreated == 0)
32767 {
32768 //ri->guyref = MAX_DWORD;
32769 ri->guyref = 0;
32770 Z_scripterrlog("Couldn't create NPC \"%s\", screen NPC limit reached\n", guy_string[ID]);
32771 }
32772 else
32773 {
32774 2363 word index = guys.Count() - numcreated; //Get the main enemy, not a segment
32775 2363 ri->guyref = guys.spr(index)->getUID();
32776
32777
2/2
✓ Branch 0 taken 2399 times.
✓ Branch 1 taken 2363 times.
4762 for(; index<guys.Count(); index++)
32778 2399 ((enemy*)guys.spr(index))->script_spawned=true;
32779
32780 2363 Z_eventlog("Script created NPC \"%s\" with UID = %ld\n", guy_string[ID], ri->guyref);
32781 }
32782 2363 }
32783
32784 ///----------------------------------------------------------------------------------------------------//
32785 //Drawing & Sound
32786
32787 173 void do_message(const bool v)
32788 {
32789 173 const int32_t ID = SH::get_arg(sarg1, v) / 10000;
32790
32791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 173 times.
173 if(BC::checkMessage(ID, "Screen->Message") != SH::_NoError)
32792 return;
32793
32794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 173 times.
173 if(ID == 0)
32795 {
32796 dismissmsg();
32797 msgfont = get_zc_font(font_zfont);
32798 blockpath = false;
32799 Hero.finishedmsg();
32800 }
32801 else
32802 173 donewmsg(ID);
32803 173 }
32804
32805 37318673 INLINE void set_drawing_command_args(const int32_t j, const word numargs)
32806 {
32807
2/2
✓ Branch 0 taken 294492690 times.
✓ Branch 1 taken 37318673 times.
331811363 for(int32_t k = 1; k <= numargs; k++)
32808 294492690 script_drawing_commands[j][k] = SH::read_stack(ri->sp + (numargs - k));
32809 37318673 }
32810
32811 661820 INLINE void set_user_bitmap_command_args(const int32_t j, const word numargs)
32812 {
32813 //ri->bitmapref = SH::read_stack(ri->sp+numargs);
32814 //zprint("Current drawing bitmap ref is: %d\n", ri->bitmapref );
32815
2/2
✓ Branch 0 taken 7096925 times.
✓ Branch 1 taken 661820 times.
7758745 for(int32_t k = 1; k <= numargs; k++)
32816 7096925 script_drawing_commands[j][k] = SH::read_stack(ri->sp + (numargs - k));
32817 661820 }
32818
32819 37980493 void do_drawing_command(const int32_t script_command)
32820 {
32821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37980493 times.
37980493 if (FFCore.skipscriptdraws)
32822 return;
32823 37980493 int32_t j = script_drawing_commands.GetNext();
32824
32825
1/2
✓ Branch 0 taken 37980493 times.
✗ Branch 1 not taken.
37980493 if(j == -1) //out of drawing command space
32826 {
32827 Z_scripterrlog("Max draw primitive limit reached\n");
32828 return;
32829 }
32830
32831 37980493 script_drawing_commands[j][0] = script_command;
32832 37980493 script_drawing_commands[j][18] = zscriptDrawingRenderTarget->GetCurrentRenderTarget(); // no fixed bs.
32833
32834
36/76
✓ Branch 0 taken 2051 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6363 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2223630 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1056651 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1850 times.
✓ Branch 9 taken 937398 times.
✓ Branch 10 taken 383247 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 829674 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1718027 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 4759287 times.
✓ Branch 21 taken 17998198 times.
✓ Branch 22 taken 936091 times.
✓ Branch 23 taken 94003 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 9270 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 802244 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 4128276 times.
✓ Branch 30 taken 49303 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 1240874 times.
✓ Branch 34 taken 150650 times.
✓ Branch 35 taken 7818 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 23008 times.
✓ Branch 38 taken 2790 times.
✓ Branch 39 taken 26528 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✓ Branch 43 taken 1480 times.
✗ Branch 44 not taken.
✓ Branch 45 taken 502 times.
✓ Branch 46 taken 144 times.
✗ Branch 47 not taken.
✓ Branch 48 taken 80910 times.
✓ Branch 49 taken 59173 times.
✗ Branch 50 not taken.
✓ Branch 51 taken 824 times.
✗ Branch 52 not taken.
✓ Branch 53 taken 166191 times.
✓ Branch 54 taken 784 times.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✓ Branch 58 taken 45504 times.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✓ Branch 63 taken 1173 times.
✗ Branch 64 not taken.
✓ Branch 65 taken 234762 times.
✓ Branch 66 taken 909 times.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✓ Branch 70 taken 906 times.
✗ Branch 71 not taken.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✗ Branch 75 not taken.
37980493 switch(script_command)
32835 {
32836 case RECTR:
32837 2223630 set_drawing_command_args(j, 12);
32838 2223630 break;
32839
32840 case FRAMER:
32841 set_drawing_command_args(j, 9);
32842 break;
32843
32844 case CIRCLER:
32845 1056651 set_drawing_command_args(j, 11);
32846 1056651 break;
32847
32848 case ARCR:
32849 set_drawing_command_args(j, 14);
32850 break;
32851
32852 case ELLIPSER:
32853 1850 set_drawing_command_args(j, 12);
32854 1850 break;
32855
32856 case LINER:
32857 937398 set_drawing_command_args(j, 11);
32858 937398 break;
32859
32860 case PUTPIXELR:
32861 383247 set_drawing_command_args(j, 8);
32862 383247 break;
32863
32864 case PIXELARRAYR:
32865 {
32866 set_drawing_command_args(j, 5);
32867 std::vector<int32_t> *v = script_drawing_commands.GetVector();
32868 //for ( int32_t q = 0; q < 6; q++ )
32869 //{
32870 // zprint("PIXELARRAY script_drawing_commands[j][%d] is %d\n", q, script_drawing_commands[j][q]);
32871 //}
32872 int32_t arrayptr = script_drawing_commands[j][2]/10000;
32873 if ( !arrayptr ) //Don't crash because of vector size.
32874 {
32875 Z_scripterrlog("Invalid array pointer %d passed to Screen->PutPixels(). Aborting.", arrayptr);
32876 break;
32877 }
32878 //zprint("Pixelarray array pointer is: %d\n", arrayptr);
32879 int32_t sz = ArrayH::getSize(arrayptr);
32880 if(!sz)
32881 {
32882 script_drawing_commands.PopLast();
32883 return;
32884 }
32885 //ArrayH::getSize(script_drawing_commands[j][2]/10000);
32886 //zprint("Pixelarray size is: %d\n", sz);
32887 v->resize(sz, 0);
32888 int32_t* pos = &v->at(0);
32889
32890 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, sz);
32891 script_drawing_commands[j].SetVector(v);
32892 break;
32893 }
32894
32895 case TILEARRAYR:
32896 {
32897 set_drawing_command_args(j, 2);
32898 std::vector<int32_t> *v = script_drawing_commands.GetVector();
32899 //for ( int32_t q = 0; q < 6; q++ )
32900 //{
32901 // zprint("PIXELARRAY script_drawing_commands[j][%d] is %d\n", q, script_drawing_commands[j][q]);
32902 //}
32903 int32_t arrayptr = script_drawing_commands[j][2]/10000;
32904 if ( !arrayptr ) //Don't crash because of vector size.
32905 {
32906 Z_scripterrlog("Invalid array pointer %d passed to Screen->DrawTiles(). Aborting.", arrayptr);
32907 break;
32908 }
32909 //zprint("Pixelarray array pointer is: %d\n", arrayptr);
32910 int32_t sz = ArrayH::getSize(arrayptr);
32911 if(!sz)
32912 {
32913 script_drawing_commands.PopLast();
32914 return;
32915 }
32916 //ArrayH::getSize(script_drawing_commands[j][2]/10000);
32917 //zprint("Pixelarray size is: %d\n", sz);
32918 v->resize(sz, 0);
32919 int32_t* pos = &v->at(0);
32920
32921 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, sz);
32922 script_drawing_commands[j].SetVector(v);
32923 break;
32924 }
32925
32926 case LINESARRAY:
32927 {
32928 set_drawing_command_args(j, 2);
32929 std::vector<int32_t> *v = script_drawing_commands.GetVector();
32930 //for ( int32_t q = 0; q < 6; q++ )
32931 //{
32932 // zprint("PIXELARRAY script_drawing_commands[j][%d] is %d\n", q, script_drawing_commands[j][q]);
32933 //}
32934 int32_t arrayptr = script_drawing_commands[j][2]/10000;
32935 if ( !arrayptr ) //Don't crash because of vector size.
32936 {
32937 Z_scripterrlog("Invalid array pointer %d passed to Screen->Lines(). Aborting.", arrayptr);
32938 break;
32939 }
32940 //zprint("Pixelarray array pointer is: %d\n", arrayptr);
32941 int32_t sz = ArrayH::getSize(arrayptr);
32942 if(!sz)
32943 {
32944 script_drawing_commands.PopLast();
32945 return;
32946 }
32947 //ArrayH::getSize(script_drawing_commands[j][2]/10000);
32948 //zprint("Pixelarray size is: %d\n", sz);
32949 v->resize(sz, 0);
32950 int32_t* pos = &v->at(0);
32951
32952 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, sz);
32953 script_drawing_commands[j].SetVector(v);
32954 break;
32955 }
32956
32957 /*
32958 historical-old-master
32959 set_drawing_command_args(j, 6);
32960 int32_t count = script_drawing_commands[j][2] / 10000; //todo: errcheck
32961
32962 int32_t* ptr = (int32_t*)script_drawing_commands.AllocateDrawBuffer(3 * count * sizeof(int32_t));
32963 int32_t* p = ptr;
32964
32965 ArrayH::getValues(script_drawing_commands[j][3] / 10000, p, count); p += count;
32966 ArrayH::getValues(script_drawing_commands[j][4] / 10000, p, count); p += count;
32967 ArrayH::getValues(script_drawing_commands[j][5] / 10000, p, count);
32968
32969 script_drawing_commands[j].SetPtr(ptr);
32970 */
32971 // Unused
32972 //const int32_t index = script_drawing_commands[j][19] = j;
32973
32974 //std::array *aptr = script_drawing_commands.GetString();
32975 //ArrayH::getString(script_drawing_commands[j][2] / 10000, *aptr);
32976 //script_drawing_commands[j].SetArray(aptr);
32977 //set_drawing_command_args(j, 2);
32978 //break;
32979
32980 case COMBOARRAYR:
32981 {
32982 set_drawing_command_args(j, 2);
32983 std::vector<int32_t> *v = script_drawing_commands.GetVector();
32984 //for ( int32_t q = 0; q < 6; q++ )
32985 //{
32986 // zprint("PIXELARRAY script_drawing_commands[j][%d] is %d\n", q, script_drawing_commands[j][q]);
32987 //}
32988 int32_t arrayptr = script_drawing_commands[j][2]/10000;
32989 if ( !arrayptr ) //Don't crash because of vector size.
32990 {
32991 Z_scripterrlog("Invalid array pointer %d passed to Screen->DrawCombos(). Aborting.", arrayptr);
32992 break;
32993 }
32994 //zprint("Pixelarray array pointer is: %d\n", arrayptr);
32995 int32_t sz = ArrayH::getSize(arrayptr);
32996 if(!sz)
32997 {
32998 script_drawing_commands.PopLast();
32999 return;
33000 }
33001 //ArrayH::getSize(script_drawing_commands[j][2]/10000);
33002 //zprint("Pixelarray size is: %d\n", sz);
33003 v->resize(sz, 0);
33004 int32_t* pos = &v->at(0);
33005
33006 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, sz);
33007 script_drawing_commands[j].SetVector(v);
33008 break;
33009 }
33010 case POLYGONR:
33011 {
33012 set_drawing_command_args(j, 5);
33013
33014 int32_t arrayptr = script_drawing_commands[j][3]/10000;
33015 if ( !arrayptr ) //Don't crash because of vector size.
33016 {
33017 Z_scripterrlog("Invalid array pointer %d passed to Screen->Polygon(). Aborting.", arrayptr);
33018 break;
33019 }
33020 int32_t sz = ArrayH::getSize(arrayptr);
33021 if(!sz)
33022 {
33023 script_drawing_commands.PopLast();
33024 return;
33025 }
33026
33027 std::vector<int32_t> *v = script_drawing_commands.GetVector();
33028 v->resize(sz, 0);
33029
33030 int32_t* pos = &v->at(0);
33031
33032
33033 ArrayH::getValues(script_drawing_commands[j][3] / 10000, pos, sz);
33034 script_drawing_commands[j].SetVector(v);
33035 }
33036 break;
33037
33038 case DRAWTILER:
33039 829674 set_drawing_command_args(j, 15);
33040 829674 break;
33041
33042 case DRAWTILECLOAKEDR:
33043 set_drawing_command_args(j, 7);
33044 break;
33045
33046 case DRAWCOMBOR:
33047 1718027 set_drawing_command_args(j, 16);
33048 1718027 break;
33049
33050 case DRAWCOMBOCLOAKEDR:
33051 set_drawing_command_args(j, 7);
33052 break;
33053
33054 case FASTTILER:
33055 4759287 set_drawing_command_args(j, 6);
33056 4759287 break;
33057
33058 case FASTCOMBOR:
33059 17998198 set_drawing_command_args(j, 6);
33060 17998198 break;
33061
33062 case DRAWCHARR:
33063 936091 set_drawing_command_args(j, 10);
33064 936091 break;
33065
33066 case DRAWINTR:
33067 94003 set_drawing_command_args(j, 11);
33068 94003 break;
33069
33070 case SPLINER:
33071 set_drawing_command_args(j, 11);
33072 break;
33073
33074 case QUADR:
33075 9270 set_drawing_command_args(j, 15);
33076 9270 break;
33077
33078 case TRIANGLER:
33079 set_drawing_command_args(j, 13);
33080 break;
33081
33082 case BITMAPR:
33083 802244 set_drawing_command_args(j, 12);
33084 802244 break;
33085
33086 case BITMAPEXR:
33087 set_drawing_command_args(j, 16);
33088 break;
33089
33090 case DRAWLAYERR:
33091 4128276 set_drawing_command_args(j, 8);
33092 4128276 break;
33093
33094 case DRAWSCREENR:
33095 49303 set_drawing_command_args(j, 6);
33096 49303 break;
33097
33098 case QUAD3DR:
33099 {
33100 set_drawing_command_args(j, 8);
33101 int32_t arrayptr = script_drawing_commands[j][2]/10000;
33102 int32_t sz = ArrayH::getSize(arrayptr);
33103 arrayptr = script_drawing_commands[j][3]/10000;
33104 sz += ArrayH::getSize(arrayptr);
33105 arrayptr = script_drawing_commands[j][4]/10000;
33106 sz += ArrayH::getSize(arrayptr);
33107 arrayptr = script_drawing_commands[j][5]/10000;
33108 sz += ArrayH::getSize(arrayptr);
33109 if(sz < 25)
33110 {
33111 script_drawing_commands.PopLast();
33112 return;
33113 }
33114 std::vector<int32_t> *v = script_drawing_commands.GetVector();
33115 v->resize(sz, 0);
33116
33117 int32_t* pos = &v->at(0);
33118 int32_t* uv = &v->at(12);
33119 int32_t* col = &v->at(20);
33120 int32_t* size = &v->at(24);
33121
33122 ArrayH::getValues((script_drawing_commands[j][2] / 10000), pos, 12);
33123 ArrayH::getValues((script_drawing_commands[j][3] / 10000), uv, 8);
33124 ArrayH::getValues((script_drawing_commands[j][4] / 10000), col, 4);
33125 //FFCore.getValues2(script_drawing_commands[j][5] / 10000, size, 2);
33126 ArrayH::getValues((script_drawing_commands[j][5] / 10000), size, 2);
33127
33128 script_drawing_commands[j].SetVector(v);
33129 }
33130 break;
33131
33132 case TRIANGLE3DR:
33133 {
33134 set_drawing_command_args(j, 8);
33135
33136 int32_t arrayptr = script_drawing_commands[j][2]/10000;
33137 int32_t sz = ArrayH::getSize(arrayptr);
33138 arrayptr = script_drawing_commands[j][3]/10000;
33139 sz += ArrayH::getSize(arrayptr);
33140 arrayptr = script_drawing_commands[j][4]/10000;
33141 sz += ArrayH::getSize(arrayptr);
33142 arrayptr = script_drawing_commands[j][5]/10000;
33143 sz += ArrayH::getSize(arrayptr);
33144 if(sz < 19)
33145 {
33146 script_drawing_commands.PopLast();
33147 return;
33148 }
33149
33150 std::vector<int32_t> *v = script_drawing_commands.GetVector();
33151 v->resize(sz, 0);
33152
33153 int32_t* pos = &v->at(0);
33154 int32_t* uv = &v->at(9);
33155 int32_t* col = &v->at(15);
33156 int32_t* size = &v->at(18);
33157
33158 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, 8);
33159 ArrayH::getValues(script_drawing_commands[j][3] / 10000, uv, 6);
33160 ArrayH::getValues(script_drawing_commands[j][4] / 10000, col, 3);
33161 ArrayH::getValues(script_drawing_commands[j][5] / 10000, size, 2);
33162
33163 script_drawing_commands[j].SetVector(v);
33164 }
33165 break;
33166
33167 case DRAWSTRINGR:
33168 {
33169 1240874 set_drawing_command_args(j, 9);
33170 // Unused
33171 //const int32_t index = script_drawing_commands[j][19] = j;
33172
33173 1240874 string *str = script_drawing_commands.GetString();
33174 1240874 ArrayH::getString(script_drawing_commands[j][8] / 10000, *str, 256);
33175 1240874 script_drawing_commands[j].SetString(str);
33176 }
33177 1240874 break;
33178
33179 case DRAWSTRINGR2:
33180 {
33181 150650 set_drawing_command_args(j, 11);
33182 // Unused
33183 //const int32_t index = script_drawing_commands[j][19] = j;
33184
33185 150650 string *str = script_drawing_commands.GetString();
33186 150650 ArrayH::getString(script_drawing_commands[j][8] / 10000, *str, 256);
33187 150650 script_drawing_commands[j].SetString(str);
33188 }
33189 150650 break;
33190
33191 case BMPRECTR:
33192 7818 set_user_bitmap_command_args(j, 12); script_drawing_commands[j][17] = SH::read_stack(ri->sp+12);
33193 //Pop the args off the stack first. Then pop the pointer and push it to sdci[17].
33194 //The pointer for the bitmap variable (its literal value) is always ri->sp+numargs, so, with 12 args, it is sp+12.
33195 7818 break;
33196
33197 case BMPFRAMER:
33198 set_user_bitmap_command_args(j, 9);
33199 script_drawing_commands[j][17] = SH::read_stack(ri->sp+9);
33200 break;
33201
33202 case CLEARBITMAP:
33203 {
33204 23008 set_user_bitmap_command_args(j, 1);
33205 23008 script_drawing_commands[j][17] = SH::read_stack(ri->sp+1);
33206 23008 break;
33207 }
33208 case BITMAPCLEARTOCOLOR:
33209 {
33210 2790 set_user_bitmap_command_args(j, 2);
33211 2790 script_drawing_commands[j][17] = SH::read_stack(ri->sp+2);
33212 2790 break;
33213 }
33214 case REGENERATEBITMAP:
33215 {
33216 26528 set_user_bitmap_command_args(j, 3);
33217 26528 script_drawing_commands[j][17] = SH::read_stack(ri->sp+3);
33218 26528 break;
33219 }
33220 case BMPPOLYGONR:
33221 {
33222 set_user_bitmap_command_args(j, 5);
33223 script_drawing_commands[j][17] = SH::read_stack(ri->sp+5);
33224 int32_t arrayptr = script_drawing_commands[j][3]/10000;
33225 if ( !arrayptr ) //Don't crash because of vector size.
33226 {
33227 Z_scripterrlog("Invalid array pointer %d passed to Screen->Polygon(). Aborting.", arrayptr);
33228 break;
33229 }
33230 int32_t sz = ArrayH::getSize(arrayptr);
33231 if(!sz)
33232 {
33233 script_drawing_commands.PopLast();
33234 return;
33235 }
33236 std::vector<int32_t> *v = script_drawing_commands.GetVector();
33237 v->resize(sz, 0);
33238
33239 int32_t* pos = &v->at(0);
33240
33241
33242 ArrayH::getValues(script_drawing_commands[j][3] / 10000, pos, sz);
33243 script_drawing_commands[j].SetVector(v);
33244 }
33245 break;
33246 case READBITMAP:
33247 {
33248 //zprint("Calling %s\n","READBITMAP");
33249 set_user_bitmap_command_args(j, 2);
33250 script_drawing_commands[j][17] = SH::read_stack(ri->sp+2);
33251 string *str = script_drawing_commands.GetString();
33252 ArrayH::getString(script_drawing_commands[j][2] / 10000, *str, 256);
33253
33254 //char cptr = new char[str->size()+1]; // +1 to account for \0 byte
33255 //strncpy(cptr, str->c_str(), str->size());
33256
33257 if(get_qr(qr_BITMAP_AND_FILESYSTEM_PATHS_ALWAYS_RELATIVE))
33258 {
33259 char buf[2048+1] = {0};
33260 if(FFCore.get_scriptfile_path(buf, str->c_str()))
33261 (*str) = buf;
33262 }
33263 regulate_path(*str);
33264
33265 //zprint("READBITMAP string is %s\n", cptr);
33266
33267 script_drawing_commands[j].SetString(str);
33268 break;
33269 }
33270 case WRITEBITMAP:
33271 {
33272 //zprint("Calling %s\n","WRITEBITMAP");
33273 set_user_bitmap_command_args(j, 3);
33274 script_drawing_commands[j][17] = SH::read_stack(ri->sp+3);
33275 std::string *str = script_drawing_commands.GetString();
33276 ArrayH::getString(script_drawing_commands[j][2] / 10000, *str, 256);
33277
33278
33279 //char *cptr = new char[str->size()+1]; // +1 to account for \0 byte
33280 //strncpy(cptr, str->c_str(), str->size());
33281
33282 if(get_qr(qr_BITMAP_AND_FILESYSTEM_PATHS_ALWAYS_RELATIVE))
33283 {
33284 char buf[2048+1] = {0};
33285 if(FFCore.get_scriptfile_path(buf, str->c_str()))
33286 (*str) = buf;
33287 }
33288 regulate_path(*str);
33289
33290 //zprint("WRITEBITMAP string is %s\n", cptr);
33291 script_drawing_commands[j].SetString(str);
33292 break;
33293 }
33294
33295 1480 case BMPCIRCLER: set_user_bitmap_command_args(j, 11); script_drawing_commands[j][17] = SH::read_stack(ri->sp+11); break;
33296 case BMPARCR: set_user_bitmap_command_args(j, 14); script_drawing_commands[j][17] = SH::read_stack(ri->sp+14); break;
33297 502 case BMPELLIPSER: set_user_bitmap_command_args(j, 12); script_drawing_commands[j][17] = SH::read_stack(ri->sp+12); break;
33298 144 case BMPLINER: set_user_bitmap_command_args(j, 11); script_drawing_commands[j][17] = SH::read_stack(ri->sp+11); break;
33299 case BMPSPLINER: set_user_bitmap_command_args(j, 11); script_drawing_commands[j][17] = SH::read_stack(ri->sp+11); break;
33300 80910 case BMPPUTPIXELR: set_user_bitmap_command_args(j, 8); script_drawing_commands[j][17] = SH::read_stack(ri->sp+8); break;
33301 59173 case BMPDRAWTILER: set_user_bitmap_command_args(j, 15); script_drawing_commands[j][17] = SH::read_stack(ri->sp+15); break;
33302 case BMPDRAWTILECLOAKEDR: set_user_bitmap_command_args(j, 7); script_drawing_commands[j][17] = SH::read_stack(ri->sp+7); break;
33303 824 case BMPDRAWCOMBOR: set_user_bitmap_command_args(j, 16); script_drawing_commands[j][17] = SH::read_stack(ri->sp+16); break;
33304 case BMPDRAWCOMBOCLOAKEDR: set_user_bitmap_command_args(j, 7); script_drawing_commands[j][17] = SH::read_stack(ri->sp+7); break;
33305 166191 case BMPFASTTILER: set_user_bitmap_command_args(j, 6); script_drawing_commands[j][17] = SH::read_stack(ri->sp+6); break;
33306 784 case BMPFASTCOMBOR: set_user_bitmap_command_args(j, 6); script_drawing_commands[j][17] = SH::read_stack(ri->sp+6); break;
33307 case BMPDRAWCHARR: set_user_bitmap_command_args(j, 10); script_drawing_commands[j][17] = SH::read_stack(ri->sp+10); break;
33308 case BMPDRAWINTR: set_user_bitmap_command_args(j, 11); script_drawing_commands[j][17] = SH::read_stack(ri->sp+11); break;
33309 case BMPDRAWSTRINGR:
33310 {
33311 set_user_bitmap_command_args(j, 9);
33312 script_drawing_commands[j][17] = SH::read_stack(ri->sp+9);
33313 // Unused
33314 //const int32_t index = script_drawing_commands[j][19] = j;
33315
33316 string *str = script_drawing_commands.GetString();
33317 ArrayH::getString(script_drawing_commands[j][8] / 10000, *str, 256);
33318 script_drawing_commands[j].SetString(str);
33319
33320 }
33321 break;
33322 case BMPDRAWSTRINGR2:
33323 {
33324 45504 set_user_bitmap_command_args(j, 11);
33325 45504 script_drawing_commands[j][17] = SH::read_stack(ri->sp+11);
33326 // Unused
33327 //const int32_t index = script_drawing_commands[j][19] = j;
33328
33329 45504 string *str = script_drawing_commands.GetString();
33330 45504 ArrayH::getString(script_drawing_commands[j][8] / 10000, *str, 256);
33331 45504 script_drawing_commands[j].SetString(str);
33332
33333 }
33334 45504 break;
33335 case BMPQUADR: set_user_bitmap_command_args(j, 16); script_drawing_commands[j][17] = SH::read_stack(ri->sp+16); break;
33336 case BMPQUAD3DR:
33337 {
33338 set_drawing_command_args(j, 9);
33339 std::vector<int32_t> *v = script_drawing_commands.GetVector();
33340 v->resize(26, 0);
33341
33342 int32_t* pos = &v->at(0);
33343 int32_t* uv = &v->at(12);
33344 int32_t* col = &v->at(20);
33345 int32_t* size = &v->at(24);
33346
33347
33348 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, 12);
33349 ArrayH::getValues(script_drawing_commands[j][3] / 10000, uv, 8);
33350 ArrayH::getValues(script_drawing_commands[j][4] / 10000, col, 4);
33351 ArrayH::getValues(script_drawing_commands[j][5] / 10000, size, 2);
33352
33353 script_drawing_commands[j].SetVector(v);
33354 script_drawing_commands[j][17] = SH::read_stack(ri->sp+9);
33355
33356 }
33357 break;
33358 case BMPTRIANGLER: set_user_bitmap_command_args(j, 14); script_drawing_commands[j][17] = SH::read_stack(ri->sp+14); break;
33359 case BMPTRIANGLE3DR:
33360 {
33361 set_drawing_command_args(j, 9);
33362
33363 std::vector<int32_t> *v = script_drawing_commands.GetVector();
33364 v->resize(20, 0);
33365
33366 int32_t* pos = &v->at(0);
33367 int32_t* uv = &v->at(9);
33368 int32_t* col = &v->at(15);
33369 int32_t* size = &v->at(18);
33370
33371
33372 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, 8);
33373 ArrayH::getValues(script_drawing_commands[j][3] / 10000, uv, 6);
33374 ArrayH::getValues(script_drawing_commands[j][4] / 10000, col, 3);
33375 ArrayH::getValues(script_drawing_commands[j][5] / 10000, size, 2);
33376
33377 script_drawing_commands[j].SetVector(v);
33378 script_drawing_commands[j][17] = SH::read_stack(ri->sp+9);
33379 break;
33380 }
33381
33382 case BMPDRAWLAYERR:
33383 1173 set_user_bitmap_command_args(j, 8);
33384 1173 script_drawing_commands[j][17] = SH::read_stack(ri->sp+8);
33385 1173 break;
33386 case BMPDRAWLAYERSOLIDR:
33387 case BMPDRAWLAYERCFLAGR:
33388 case BMPDRAWLAYERCTYPER:
33389 case BMPDRAWLAYERCIFLAGR:
33390 case BMPDRAWLAYERSOLIDITYR: set_user_bitmap_command_args(j, 9); script_drawing_commands[j][17] = SH::read_stack(ri->sp+9); break;
33391 case BMPDRAWSCREENR:
33392 case BMPDRAWSCREENSOLIDR:
33393 case BMPDRAWSCREENSOLID2R:
33394 case BMPDRAWSCREENCOMBOFR:
33395 case BMPDRAWSCREENCOMBOIR:
33396 case BMPDRAWSCREENCOMBOTR:
33397 2051 set_user_bitmap_command_args(j, 6); script_drawing_commands[j][17] = SH::read_stack(ri->sp+6); break;
33398 case BITMAPGETPIXEL:
33399 {
33400 //UNUSED
33401 // for(int32_t q = 0; q < 20; q++)
33402 // {
33403 // Z_scripterrlog("getpixel SH::read_stack(ri->sp+%d) is: %d\n", q, SH::read_stack(ri->sp+q));
33404 // }
33405 set_user_bitmap_command_args(j, 3); script_drawing_commands[j][17] = SH::read_stack(ri->sp+3);
33406 break;
33407 }
33408 case BMPBLIT:
33409 {
33410 234762 set_user_bitmap_command_args(j, 16);
33411 //for(int32_t q = 0; q < 8; ++q )
33412 //Z_scripterrlog("FFscript blit() ri->d[%d] is: %d\n", q, ri->d[q]);
33413 234762 script_drawing_commands[j][17] = SH::read_stack(ri->sp+16);
33414 234762 break;
33415 }
33416 case BMPBLITTO:
33417 {
33418 909 set_user_bitmap_command_args(j, 16);
33419 //for(int32_t q = 0; q < 8; ++q )
33420 //Z_scripterrlog("FFscript blit() ri->d[%d] is: %d\n", q, ri->d[q]);
33421 909 script_drawing_commands[j][17] = SH::read_stack(ri->sp+16);
33422 909 break;
33423 }
33424 case BMPMODE7:
33425 {
33426 set_user_bitmap_command_args(j, 13);
33427 //for(int32_t q = 0; q < 8; ++q )
33428 //Z_scripterrlog("FFscript blit() ri->d[%d] is: %d\n", q, ri->d[q]);
33429 script_drawing_commands[j][17] = SH::read_stack(ri->sp+13);
33430 break;
33431 }
33432
33433 case BMPWRITETILE:
33434 {
33435 set_user_bitmap_command_args(j, 6);
33436 script_drawing_commands[j][17] = SH::read_stack(ri->sp+6);
33437 break;
33438 }
33439 case BMPDITHER:
33440 {
33441 set_user_bitmap_command_args(j, 5);
33442 script_drawing_commands[j][17] = SH::read_stack(ri->sp+5);
33443 break;
33444 }
33445 case BMPMASKDRAW:
33446 {
33447 906 set_user_bitmap_command_args(j, 3);
33448 906 script_drawing_commands[j][4] = 0x01 * 10000L;
33449 906 script_drawing_commands[j][5] = 0xFF * 10000L;
33450 906 script_drawing_commands[j][17] = SH::read_stack(ri->sp+3);
33451 906 break;
33452 }
33453 case BMPMASKDRAW2:
33454 {
33455 set_user_bitmap_command_args(j, 4);
33456 script_drawing_commands[j][5] = script_drawing_commands[j][4];
33457 script_drawing_commands[j][0] = BMPMASKDRAW;
33458 script_drawing_commands[j][17] = SH::read_stack(ri->sp+4);
33459 break;
33460 }
33461 case BMPMASKDRAW3:
33462 {
33463 set_user_bitmap_command_args(j, 5);
33464 script_drawing_commands[j][0] = BMPMASKDRAW;
33465 script_drawing_commands[j][17] = SH::read_stack(ri->sp+5);
33466 break;
33467 }
33468 case BMPMASKBLIT:
33469 {
33470 set_user_bitmap_command_args(j, 4);
33471 script_drawing_commands[j][5] = 0x01 * 10000L;
33472 script_drawing_commands[j][6] = 0xFF * 10000L;
33473 script_drawing_commands[j][17] = SH::read_stack(ri->sp+4);
33474 break;
33475 }
33476 case BMPMASKBLIT2:
33477 {
33478 set_user_bitmap_command_args(j, 5);
33479 script_drawing_commands[j][6] = script_drawing_commands[j][5];
33480 script_drawing_commands[j][0] = BMPMASKBLIT;
33481 script_drawing_commands[j][17] = SH::read_stack(ri->sp+5);
33482 break;
33483 }
33484 case BMPMASKBLIT3:
33485 {
33486 set_user_bitmap_command_args(j, 6);
33487 script_drawing_commands[j][0] = BMPMASKBLIT;
33488 script_drawing_commands[j][17] = SH::read_stack(ri->sp+6);
33489 break;
33490 }
33491 case BMPREPLCOLOR:
33492 case BMPSHIFTCOLOR:
33493 {
33494 6363 set_user_bitmap_command_args(j, 4);
33495 6363 script_drawing_commands[j][17] = SH::read_stack(ri->sp+4);
33496 6363 break;
33497 }
33498 }
33499 37980493 script_drawing_commands.mark_dirty(script_drawing_commands[j][1]/10000);
33500 37980493 }
33501
33502 3535588 void do_set_rendertarget(bool)
33503 {
33504 3535588 int32_t target = int32_t(SH::read_stack(ri->sp) / 10000);
33505 3535588 zscriptDrawingRenderTarget->SetCurrentRenderTarget(target);
33506 3535588 }
33507
33508 170878 void do_sfx(const bool v)
33509 {
33510 170878 int32_t ID = SH::get_arg(sarg1, v) / 10000;
33511
33512
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 170874 times.
170878 if(BC::checkSFXID(ID, "Game->PlaySound") != SH::_NoError)
33513 4 return;
33514
33515 170874 sfx(ID);
33516 170878 }
33517
33518 void do_sfx_ex(const bool restart)
33519 {
33520 int32_t ID = SH::read_stack(ri->sp + 4) / 10000;
33521 int32_t vol = vbound(SH::read_stack(ri->sp + 3), 0, 10000 * 100);
33522 int32_t pan = vbound(SH::read_stack(ri->sp + 2)/10000 + 128, 0, 255);
33523 int32_t freq = SH::read_stack(ri->sp + 1);
33524 bool loop = SH::read_stack(ri->sp) / 10000;
33525
33526 if (BC::checkSFXID(ID, restart?"Audio->PlaySound":"Audio->AdjustSound") != SH::_NoError)
33527 return;
33528
33529 if (!restart && !sfx_allocated(ID))
33530 return;
33531
33532 sfx(ID, pan, loop, restart, vol, freq);
33533 }
33534
33535 static int get_sfx_completion()
33536 {
33537 int32_t ID = get_register(sarg1) / 10000;
33538
33539 if (!sfx_allocated(ID))
33540 {
33541 return -10000;
33542 }
33543
33544 uint64_t sample_pos = voice_get_position(sfx_voice[ID]);
33545
33546 if (sample_pos < 0)
33547 {
33548 return -10000;
33549 }
33550
33551 uint32_t sample_length = sfx_get_length(ID);
33552 uint64_t res = (sample_pos * 10000 * 100) / sample_length;
33553 return int32_t(res);
33554 }
33555
33556 void do_get_sfx_completion()
33557 {
33558 int32_t ID = get_register(sarg1) / 10000;
33559 if (replay_is_active())
33560 replay_step_comment(fmt::format("ID {}", ID));
33561 int32_t value = replay_get_state(ReplayStateType::SfxPosition, get_sfx_completion);
33562 set_register(sarg1, value);
33563 }
33564
33565 int32_t FFScript::do_get_internal_uid_npc(int32_t index)
33566 {
33567 return ((int32_t)guys.spr(index)->getUID());
33568 }
33569 int32_t FFScript::do_get_internal_uid_item(int32_t index)
33570 {
33571 return ((int32_t)items.spr(index)->getUID());
33572 }
33573 int32_t FFScript::do_get_internal_uid_lweapon(int32_t index)
33574 {
33575 return ((int32_t)Lwpns.spr(index)->getUID());
33576 }
33577 int32_t FFScript::do_get_internal_uid_eweapon(int32_t index)
33578 {
33579 return ((int32_t)Ewpns.spr(index)->getUID());
33580 }
33581
33582 void FFScript::AlloffLimited(int32_t flagset)
33583 {
33584 clear_bitmap(msg_txt_display_buf);
33585 clear_bitmap(msg_bg_display_buf);
33586 clear_bitmap(msg_portrait_display_buf);
33587 set_clip_state(msg_txt_display_buf, 1);
33588 set_clip_state(msg_bg_display_buf, 1);
33589 set_clip_state(msg_portrait_display_buf, 1);
33590
33591
33592 clear_bitmap(pricesdisplaybuf);
33593 set_clip_state(pricesdisplaybuf, 1);
33594
33595 if(items.idCount(iPile))
33596 {
33597 loadlvlpal(DMaps[currdmap].color);
33598 }
33599
33600 /*
33601
33602 #define warpFlagCLEARITEMS 0x200
33603 #define warpFlagCLEARGUYS 0x400
33604 #define warpFlagCLEARLWEAPONS 0x800
33605 #define warpFlagCLEAREWEAPONS 0x1000
33606 #define warpFlagCLEARHOOKSHOT 0x2000
33607 #define warpFlagCLEARDECORATIONS 0x4000
33608 #define warpFlagCLEARPARTICLES 0x8000
33609 */
33610
33611 if ( (flagset&warpFlagCLEARITEMS) ) items.clear();
33612 if ( (flagset&warpFlagCLEARGUYS) ) guys.clear();
33613 if ( (flagset&warpFlagCLEARLWEAPONS) ) Lwpns.clear();
33614 if ( (flagset&warpFlagCLEAREWEAPONS) ) Ewpns.clear();
33615 if ( (flagset&warpFlagCLEARHOOKSHOT) )
33616 {
33617 chainlinks.clear();
33618 Hero.reset_hookshot();
33619 }
33620 if ( (flagset&warpFlagCLEARDECORATIONS) ) decorations.clear();
33621 if ( (flagset&warpFlagCLEARPARTICLES) ) particles.clear();
33622 clearScriptHelperData();
33623
33624
33625
33626 clearScriptHelperData();
33627
33628 lensclk = 0;
33629 lensid=-1;
33630 drawguys=true;
33631 down_control_states[btnUp] =
33632 down_control_states[btnDown] =
33633 down_control_states[btnLeft] =
33634 down_control_states[btnRight] =
33635 down_control_states[btnA] =
33636 down_control_states[btnB] =
33637 down_control_states[btnS] = true;
33638
33639 if(watch && !cheat_superman)
33640 {
33641 Hero.setClock(false);
33642 }
33643
33644 // if(watch)
33645 // Hero.setClock(false);
33646 watch=freeze_guys=loaded_guys=loaded_enemies=blockpath=false;
33647
33648 for(int32_t i=0; i<176; i++)
33649 guygrid[i]=0;
33650
33651 for(int32_t i=0; i<MAXFFCS; i++)
33652 guygridffc[i]=0;
33653
33654
33655 sle_clk=0;
33656
33657 if(usebombpal)
33658 {
33659 memcpy(RAMpal, tempbombpal, PAL_SIZE*sizeof(RGB));
33660 refreshpal=true;
33661 usebombpal=false;
33662 }
33663
33664
33665 }
33666
33667 32 void doWarpEffect(int32_t warpEffect, bool out)
33668 {
33669
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
32 switch(warpEffect)
33670 {
33671 case warpEffectZap:
33672 if(out) zapout();
33673 else zapin();
33674 break;
33675 case warpEffectWave:
33676 if(out) wavyout(false);
33677 else wavyin();
33678 break;
33679 case warpEffectInstant:
33680 if(out) blackscr(30,true);
33681 break;
33682 case warpEffectMozaic:
33683 //!TODO Unimplemented
33684 break;
33685 case warpEffectOpen:
33686 if(out) closescreen();
33687 else openscreen();
33688 break;
33689 }
33690 32 }
33691
33692 void FFScript::queueWarp(int32_t wtype, int32_t tdm, int32_t tscr, int32_t wx, int32_t wy,
33693 int32_t weff, int32_t wsfx, int32_t wflag, int32_t wdir)
33694 {
33695 warpex[wexActive] = 1;
33696 warpex[wexType] = wtype;
33697 warpex[wexDMap] = tdm;
33698 warpex[wexScreen] = tscr;
33699 warpex[wexX] = wx;
33700 warpex[wexY] = wy;
33701 warpex[wexEffect] = weff;
33702 warpex[wexSound] = wsfx;
33703 warpex[wexFlags] = wflag;
33704 warpex[wexDir] = wdir;
33705 }
33706
33707 16 bool FFScript::warp_player(int32_t warpType, int32_t dmapID, int32_t scrID, int32_t warpDestX, int32_t warpDestY, int32_t warpEffect, int32_t warpSound, int32_t warpFlags, int32_t heroFacesDir)
33708 {
33709 if(DEVLOGGING)
33710 {
33711 zprint("FFScript::warp_player() arg %s is: %d \n", "warpType", warpType);
33712 zprint("FFScript::warp_player() arg %s is: %d \n", "dmapID", dmapID);
33713 zprint("FFScript::warp_player() arg %s is: %d \n", "scrID", scrID);
33714 zprint("FFScript::warp_player() arg %s is: %d \n", "warpDestX", warpDestX);
33715 zprint("FFScript::warp_player() arg %s is: %d \n", "warpDestY", warpDestY);
33716 zprint("FFScript::warp_player() arg %s is: %d \n", "warpEffect", warpEffect);
33717 zprint("FFScript::warp_player() arg %s is: %d \n", "warpSound", warpSound);
33718 zprint("FFScript::warp_player() arg %s is: %d \n", "warpFlags", warpFlags);
33719 zprint("FFScript::warp_player() arg %s is: %d \n", "heroFacesDir", heroFacesDir);
33720 }
33721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( ((unsigned)dmapID) >= MAXDMAPS )
33722 {
33723 Z_scripterrlog("Invalid DMap ID (%d) passed to WarpEx(). Aborting.\n", dmapID);
33724 return false;
33725 }
33726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( ((unsigned)scrID) >= MAPSCRS )
33727 {
33728 Z_scripterrlog("Invalid Screen ID (%d) passed to WarpEx(). Aborting.\n", scrID);
33729 return false;
33730 }
33731 //Extra sanity guard.
33732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( DMaps[dmapID].map*MAPSCRS+DMaps[dmapID].xoff+scrID >= (int32_t)TheMaps.size() )
33733 {
33734 Z_scripterrlog("Invalid destination passed to WarpEx(). Aborting.\n");
33735 return false;
33736 }
33737 16 byte t = 0;
33738 16 t=(currscr<128)?0:1;
33739 16 bool overlay=false;
33740 16 bool intradmap = (dmapID == currdmap);
33741 16 int32_t olddmap = currdmap;
33742 //if ( intradmap )
33743 //{
33744 // initZScriptDMapScripts(); //Not needed.
33745 //}
33746
33747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( warpType == wtNOWARP ) { Z_eventlog("Used a Cancel Warped to DMap %d: %s, screen %d", currdmap, DMaps[currdmap].name,currscr); return false; }
33748 16 int32_t mapID = (DMaps[dmapID].map+1);
33749 16 int32_t dest_dmap_xoff = DMaps[dmapID].xoff;
33750 //mapscr *m = &TheMaps[mapID * MAPSCRS + scrID];
33751
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 mapscr *m = &TheMaps[(zc_max((mapID)-1,0) * MAPSCRS + dest_dmap_xoff + scrID)];
33752
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( warpFlags&warpFlagNOSTEPFORWARD ) FFCore.temp_no_stepforward = 1;
33753 16 int32_t wx = 0, wy = 0;
33754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( warpDestX < 0 )
33755 {
33756 if(DEVLOGGING) zprint("WarpEx() was set to warp return point:%d\n", warpDestY);
33757
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( (unsigned)warpDestY < 4 )
33758 {
33759 16 wx = m->warpreturnx[warpDestY];
33760 16 wy = m->warpreturny[warpDestY];
33761 if(DEVLOGGING)
33762 {
33763 zprint("WarpEx Return Point X is: %d\n",wx);
33764 zprint("WarpEx Return Point Y is: %d\n",wy);
33765 }
33766 16 }
33767 else
33768 {
33769 if ( warpDestY == 5 || warpDestY < 0)
33770 {
33771 //Pit warp
33772 wx = Hero.getX();
33773 wy = Hero.getY();
33774 }
33775 else
33776 {
33777 Z_scripterrlog("Invalid Warp Return Square Type (%d) provided as an arg to Player->WarpEx().\n",warpDestY);
33778 return false;
33779 }
33780 }
33781 16 }
33782 else
33783 {
33784 if ( (unsigned)warpDestX < 256 && (unsigned)warpDestY < 176 )
33785 {
33786 wx = warpDestX;
33787 wy = warpDestY;
33788 }
33789 else
33790 {
33791 Z_scripterrlog("Invalid pixel coordinates of x = %d, y = %d, supplied to Player->WarpEx()\n",warpDestX,warpDestY);
33792 return false;
33793 }
33794
33795 }
33796 //zprint("FFCore.warp_player reached line: %d \n", 15918);
33797 //warp coordinates are wx, wy, not x, y! -Z
33798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( !(warpFlags&warpFlagDONTKILLSCRIPTDRAWS) ) script_drawing_commands.Clear();
33799 //we also need to check if dmaps are sideview here! -Z
33800 //Likewise, we need to add that check to the normal Hero:;dowarp(0
33801 16 bool wasSideview = isSideViewGravity(t); //((tmpscr[t].flags7 & fSIDEVIEW)!=0 || DMaps[currdmap].sideview) && !ignoreSideview;
33802 //zprint("FFCore.warp_player reached line: %d \n", 15925);
33803 //zprint("FFCore.warp_player war type is: %d \n", warpType);
33804
33805 //int32_t last_entr_scr = -1;
33806 //int32_t last_entr_dmap = -1;
33807
33808
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( warpType < wtEXIT ) warpType = wtIWARP; //Sanity check. We can't use wtCave, or wtPassage, with scritped warps at present.
33809 16 Hero.is_warping = true;
33810
1/5
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
16 switch(warpType)
33811 {
33812
33813 //wtCAVE, wtPASS, wtEXIT, wtSCROLL, wtIWARP, wtIWARPBLK, wtIWARPOPEN,
33814 //wtIWARPZAP, wtIWARPWAVE, wtNOWARP, wtWHISTLE, wtMAX
33815
33816
33817 case wtIWARP:
33818 case wtIWARPBLK:
33819 case wtIWARPOPEN:
33820 case wtIWARPZAP:
33821 case wtIWARPWAVE:
33822 {
33823 //zprint("FFCore.warp_player reached line: %d \n", 15936);
33824 16 bool wasswimming = (Hero.getAction()==swimming);
33825 16 bool wassideswim = (Hero.getAction()==sideswimming);
33826 16 int32_t olddiveclk = Hero.diveclk;
33827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( !(warpFlags&warpFlagDONTCLEARSPRITES) )
33828 {
33829 16 ALLOFF();
33830 16 }
33831 else FFCore.AlloffLimited(warpFlags);
33832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( !(warpFlags&warpFlagDONTKILLMUSIC) ) music_stop();
33833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( !(warpFlags&warpFlagDONTKILLSOUNDS) ) kill_sfx();
33834 16 sfx(warpSound);
33835
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(wasswimming)
33836 {
33837 Hero.setAction(swimming); FFCore.setHeroAction(swimming);
33838 Hero.diveclk = olddiveclk;
33839 }
33840
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(wassideswim)
33841 {
33842 Hero.setAction(sideswimming); FFCore.setHeroAction(sideswimming);
33843 Hero.diveclk = 0;
33844 }
33845 //zprint("FFCore.warp_player reached line: %d \n", 15948);
33846 16 doWarpEffect(warpEffect, true);
33847 //zprint("FFCore.warp_player reached line: %d \n", 15973);
33848 16 int32_t c = DMaps[currdmap].color;
33849 16 bool changedlevel = false;
33850 16 bool changeddmap = false;
33851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(currdmap != dmapID)
33852 {
33853 16 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
33854 16 changeddmap = true;
33855 16 }
33856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(dlevel != DMaps[dmapID].level)
33857 {
33858 16 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
33859 16 changedlevel = true;
33860 16 }
33861 16 dlevel = DMaps[dmapID].level;
33862 16 currdmap = dmapID;
33863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(changeddmap)
33864 {
33865 16 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
33866 16 }
33867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(changedlevel)
33868 {
33869 16 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
33870 16 }
33871 16 currmap = DMaps[currdmap].map;
33872 16 init_dmap();
33873 16 update_subscreens(dmapID);
33874
33875 16 ringcolor(false);
33876
33877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(DMaps[currdmap].color != c)
33878 16 loadlvlpal(DMaps[currdmap].color);
33879
33880 16 homescr = currscr = scrID + DMaps[currdmap].xoff;
33881
33882 16 lightingInstant(); // Also sets naturaldark
33883
33884 16 loadscr(0,currdmap,currscr,-1,overlay);
33885
33886 16 Hero.x = (zfix)wx;
33887 16 Hero.y = (zfix)wy;
33888
33889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 switch(heroFacesDir)
33890 {
33891 case up:
33892 case down:
33893 case left:
33894 case right:
33895 Hero.dir = heroFacesDir;
33896 break;
33897 default:
33898
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if((int32_t)Hero.x==(zfix)0)
33899 {
33900 Hero.dir=right;
33901 }
33902
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if((int32_t)Hero.x==(zfix)240)
33903 {
33904 Hero.dir=left;
33905 }
33906
33907
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if((int32_t)Hero.y==(zfix)0)
33908 {
33909 Hero.dir=down;
33910 }
33911
33912
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if((int32_t)Hero.y==(zfix)160)
33913 {
33914 Hero.dir=up;
33915 }
33916 16 }
33917
33918 16 markBmap(Hero.dir^1);
33919
33920
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
16 if(iswaterex(MAPCOMBO((int32_t)Hero.x,(int32_t)Hero.y+8), currmap, currscr, -1, Hero.x, Hero.y+8, true) && _walkflag((int32_t)Hero.x,(int32_t)Hero.y+8,0) && current_item(itype_flippers))
33921 {
33922 Hero.hopclk=0xFF;
33923 Hero.attackclk = Hero.charging = Hero.spins = 0;
33924 if (isSideViewHero() && get_qr(qr_SIDESWIM)) {Hero.setAction(sideswimming); FFCore.setHeroAction(sideswimming);}
33925 else {Hero.setAction(swimming); FFCore.setHeroAction(swimming);}
33926 }
33927 else
33928 {
33929 16 Hero.setAction(none); FFCore.setHeroAction(none);
33930 }
33931
33932 //preloaded freeform combos
33933 16 ffscript_engine(true);
33934
33935 16 putscr(scrollbuf,0,0,tmpscr);
33936 16 putscrdoors(scrollbuf,0,0,tmpscr);
33937
33938 16 doWarpEffect(warpEffect, false);
33939 16 show_subscreen_life=true;
33940 16 show_subscreen_numbers=true;
33941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( !(warpFlags&warpFlagDONTKILLMUSIC) ) Play_Level_Music();
33942 16 currcset=DMaps[currdmap].color;
33943 16 dointro();
33944 16 Hero.set_respawn_point();
33945 16 Hero.trySideviewLadder();
33946
33947 16 break;
33948 }
33949
33950
33951 case wtEXIT:
33952 {
33953 //zprint("%s was called with a warp type of Entrance/Exit\n", "Player->WarpEx()");
33954 lighting(false,false,pal_litRESETONLY);//Reset permLit, and do nothing else; lighting was not otherwise called on a wtEXIT warp.
33955 ALLOFF();
33956 if ( !(warpFlags&warpFlagDONTKILLMUSIC) ) music_stop();
33957 if ( !(warpFlags&warpFlagDONTKILLSOUNDS) ) kill_sfx();
33958 sfx(warpSound);
33959 blackscr(30,false);
33960 bool changedlevel = false;
33961 bool changeddmap = false;
33962 if(currdmap != dmapID)
33963 {
33964 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
33965 changeddmap = true;
33966 }
33967 if(dlevel != DMaps[dmapID].level)
33968 {
33969 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
33970 changedlevel = true;
33971 }
33972 dlevel = DMaps[dmapID].level;
33973 currdmap = dmapID;
33974 if(changeddmap)
33975 {
33976 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
33977 }
33978 if(changedlevel)
33979 {
33980 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
33981 }
33982 currmap=DMaps[currdmap].map;
33983 init_dmap();
33984 update_subscreens(dmapID);
33985 loadfullpal();
33986 ringcolor(false);
33987 loadlvlpal(DMaps[currdmap].color);
33988 //lastentrance_dmap = currdmap;
33989 homescr = currscr = scrID + DMaps[currdmap].xoff;
33990 loadscr(0,currdmap,currscr,-1,overlay);
33991
33992 if((tmpscr->flags&fDARK) && !get_qr(qr_NEW_DARKROOM))
33993 {
33994 if(get_qr(qr_FADE))
33995 {
33996 interpolatedfade();
33997 }
33998 else
33999 {
34000 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
34001 }
34002
34003 darkroom=naturaldark=true;
34004 }
34005 else
34006 {
34007 darkroom=naturaldark=false;
34008 }
34009
34010
34011 //Move Player's coordinates
34012 Hero.x = (zfix)wx;
34013 Hero.y = (zfix)wy;
34014 //set his dir
34015 switch(heroFacesDir)
34016 {
34017 case up:
34018 case down:
34019 case left:
34020 case right:
34021 Hero.dir = heroFacesDir;
34022 break;
34023 default:
34024 Hero.dir=down;
34025 if((int32_t)Hero.x==(zfix)0)
34026 {
34027 Hero.dir=right;
34028 }
34029 if((int32_t)Hero.x==(zfix)240)
34030 {
34031 Hero.dir=left;
34032 }
34033
34034 if((int32_t)Hero.y==(zfix)0)
34035 {
34036 Hero.dir=down;
34037 }
34038
34039 if((int32_t)Hero.y==(zfix)160)
34040 {
34041 Hero.dir=up;
34042 }
34043 }
34044
34045 if(dlevel)
34046 {
34047 // reset enemy kill counts
34048 for(int32_t i=0; i<128; i++)
34049 {
34050 game->guys[(currmap*MAPSCRSNORMAL)+i] = 0;
34051 game->maps[(currmap*MAPSCRSNORMAL)+i] &= ~mTMPNORET;
34052 }
34053 }
34054
34055 markBmap(Hero.dir^1);
34056 //preloaded freeform combos
34057 ffscript_engine(true);
34058 Hero.reset_hookshot();
34059
34060 if(isdungeon())
34061 {
34062 openscreen();
34063 if(get_er(er_SHORTDGNWALK)==0 && get_qr(qr_SHORTDGNWALK)==0)
34064 Hero.stepforward(Hero.diagonalMovement?11:12, false);
34065 else
34066 // Didn't walk as far pre-1.93, and some quests depend on that
34067 Hero.stepforward(8, false);
34068 }
34069 else
34070 {
34071 openscreen();
34072 }
34073
34074 show_subscreen_life=true;
34075 show_subscreen_numbers=true;
34076 Play_Level_Music();
34077 currcset=DMaps[currdmap].color;
34078 dointro();
34079 Hero.set_respawn_point();
34080 Hero.trySideviewLadder();
34081
34082 for(int32_t i=0; i<6; i++)
34083 visited[i]=-1;
34084
34085 //last_entr_scr = scrID;
34086 //last_entr_dmap = dmapID;
34087
34088 break;
34089
34090 }
34091 case wtSCROLL: // scrolling warp
34092 {
34093 int32_t c = DMaps[currdmap].color;
34094 scrolling_map = currmap;
34095 currmap = DMaps[dmapID].map;
34096 update_subscreens(dmapID);
34097
34098 dlevel = DMaps[dmapID].level;
34099 //check if Hero has the map for the new location before updating the subscreen. ? -Z
34100 //This works only in one direction, if Hero had a map, to not having one.
34101 //If Hero does not have a map, and warps somewhere where he does, then the map still briefly shows.
34102 update_subscreens(dmapID);
34103
34104 // if ( has_item(itype_map, dlevel) )
34105 // {
34106 // //Blank the map during an intra-dmap scrolling warp.
34107 // dlevel = -1; //a hack for the minimap. This works!! -Z
34108 // }
34109
34110 // fix the scrolling direction, if it was a tile or instant warp
34111 Hero.sdir = vbound(Hero.dir,0,3);
34112
34113
34114 Hero.scrollscr(Hero.sdir, scrID+DMaps[dmapID].xoff, dmapID);
34115 bool changedlevel = false;
34116 bool changeddmap = false;
34117 if(currdmap != dmapID)
34118 {
34119 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
34120 changeddmap = true;
34121 }
34122 if(dlevel != DMaps[dmapID].level)
34123 {
34124 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
34125 changedlevel = true;
34126 }
34127 dlevel = DMaps[dmapID].level;
34128 currdmap = dmapID;
34129 if(changeddmap)
34130 {
34131 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
34132 }
34133 if(changedlevel)
34134 {
34135 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
34136 }
34137
34138 Hero.reset_hookshot();
34139
34140 if(!intradmap)
34141 {
34142 currdmap = dmapID;
34143 dlevel = DMaps[currdmap].level;
34144 homescr = currscr = scrID + DMaps[dmapID].xoff;
34145 init_dmap();
34146
34147
34148 if(((wx>0||wy>0)||(get_qr(qr_WARPSIGNOREARRIVALPOINT)))&&(!get_qr(qr_NOSCROLLCONTINUE))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
34149 {
34150 if(dlevel)
34151 {
34152 lastentrance = currscr;
34153 }
34154 else
34155 {
34156 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
34157 }
34158
34159 lastentrance_dmap = dmapID;
34160 }
34161 }
34162
34163 if(DMaps[currdmap].color != c)
34164 {
34165 lighting(false, true);
34166 }
34167
34168 Play_Level_Music();
34169 currcset=DMaps[currdmap].color;
34170 dointro();
34171 break;
34172 }
34173 //Cannot use these types with scripts, or with strings.
34174 case wtCAVE:
34175 case wtPASS:
34176 case wtWHISTLE:
34177 default:
34178 {
34179 Z_scripterrlog("Invalid warp type (%d) supplied to Hero->WarpEx()!. Cannot warp!!\n", warpType);
34180 Hero.is_warping = false;
34181 return false;
34182 }
34183 }
34184 // Stop Hero from drowning!
34185
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(Hero.getAction()==drowning)
34186 {
34187 Hero.drownclk=0;
34188 Hero.setAction(none); FFCore.setHeroAction(none);
34189 }
34190
34191 // But keep him swimming if he ought to be!
34192
3/8
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
16 if(Hero.getAction()!=rafting && iswaterex(MAPCOMBO((int32_t)Hero.x,(int32_t)Hero.y+8), currmap, currscr, -1, Hero.x, Hero.y+8, true) && (_walkflag((int32_t)Hero.x,(int32_t)Hero.y+8,0) || get_qr(qr_DROWN))
34193 && (current_item(itype_flippers)) && (Hero.getAction()!=inwind))
34194 {
34195 Hero.hopclk=0xFF;
34196 if (isSideViewHero() && get_qr(qr_SIDESWIM)) {Hero.setAction(sideswimming); FFCore.setHeroAction(sideswimming);}
34197 else {Hero.setAction(swimming); FFCore.setHeroAction(swimming);}
34198 }
34199
34200 16 newscr_clk=frame;
34201 16 activated_timed_warp=false;
34202 16 eat_buttons();
34203
34204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(warpType!=wtIWARP) { Hero.attackclk=0; }
34205
34206 16 Hero.didstuff=0;
34207 16 Hero.usecounts.clear();
34208 16 map_bkgsfx(true);
34209 16 loadside=Hero.dir^1;
34210 16 whistleclk=-1;
34211
34212
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 if(((int32_t)Hero.z>0 || (int32_t)Hero.fakez>0) && isSideViewHero())
34213 {
34214 Hero.y-=Hero.z;
34215 Hero.y-=Hero.fakez;
34216 Hero.z=0;
34217 Hero.fakez=0;
34218 }
34219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 else if(!isSideViewHero())
34220 {
34221 16 Hero.fall=0;
34222 16 Hero.fakefall=0;
34223 16 }
34224
34225 // If warping between top-down and sideview screens,
34226 // fix enemies that are carried over by Full Screen Warp
34227 16 const bool tmpscr_is_sideview = isSideViewGravity();
34228
34229
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 if(!wasSideview && tmpscr_is_sideview)
34230 {
34231 for(int32_t i=0; i<guys.Count(); i++)
34232 {
34233 if(guys.spr(i)->z > 0)
34234 {
34235 guys.spr(i)->y -= guys.spr(i)->z;
34236 guys.spr(i)->z = 0;
34237 }
34238
34239 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
34240 guys.spr(i)->yofs += 2;
34241 }
34242 }
34243
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 else if(wasSideview && !tmpscr_is_sideview)
34244 {
34245 for(int32_t i=0; i<guys.Count(); i++)
34246 {
34247 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
34248 guys.spr(i)->yofs -= 2;
34249 }
34250 }
34251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( warpType == wtEXIT )
34252 {
34253 //game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
34254 game->set_continue_scrn(scrID);
34255 game->set_continue_dmap(dmapID);
34256 lastentrance = scrID;
34257 //zprint("Setting Last Entrance to: %d\n", scrID);
34258 //zprint("lastentrance = %d\n",lastentrance);
34259 lastentrance_dmap = dmapID;
34260 //zprint("Setting Last Entrance DMap to: %d\n", dmapID);
34261 //zprint("lastentrance_dmap = %d\n",lastentrance_dmap);
34262 //lastentrance_dmap = currdmap;
34263 //lastentrance = game->get_continue_scrn();
34264 }
34265 else
34266 {
34267
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( (warpFlags&warpFlagSETENTRANCESCREEN) ) lastentrance = scrID;
34268
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( (warpFlags&warpFlagSETENTRANCEDMAP) ) lastentrance_dmap = dmapID;
34269
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( (warpFlags&warpFlagSETCONTINUESCREEN) ) game->set_continue_scrn(scrID);
34270
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( (warpFlags&warpFlagSETCONTINUEDMAP) ) game->set_continue_dmap(dmapID);
34271
34272
34273 }
34274
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tmpscr->flags4&fAUTOSAVE)
34275 {
34276 save_game(true,0);
34277 }
34278
34279
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tmpscr->flags6&fCONTINUEHERE)
34280 {
34281 lastentrance_dmap = currdmap;
34282 lastentrance = homescr;
34283 }
34284
34285 16 update_subscreens();
34286 16 verifyBothWeapons();
34287 32 Z_eventlog("Warped to DMap %d: %s, screen %d, via %s.\n", currdmap, DMaps[currdmap].name,currscr,
34288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
32 warpType==wtEXIT ? "Entrance/Exit" :
34289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 warpType==wtSCROLL ? "Scrolling Warp" :
34290 16 warpType==wtNOWARP ? "Cancel Warp" :
34291 "Insta-Warp");
34292
34293 16 eventlog_mapflags();
34294
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if (((warpFlags&warpFlagDONTRESTARTDMAPSCRIPT) != 0) == (get_qr(qr_SCRIPT_WARPS_DMAP_SCRIPT_TOGGLE) != 0)|| olddmap != currdmap) //Changed DMaps, or needs to reset the script
34295 {
34296 16 FFScript::deallocateAllScriptOwned(ScriptType::DMap, olddmap);
34297 16 initZScriptDMapScripts();
34298 16 }
34299 16 Hero.is_warping = false;
34300
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!get_qr(qr_SCROLLWARP_NO_RESET_FRAME))
34301 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
34302 16 return true;
34303 16 }
34304
34305 void FFScript::do_adjustvolume(const bool v)
34306 {
34307 if (get_qr(qr_OLD_SCRIPT_VOLUME))
34308 {
34309 int32_t perc = (SH::get_arg(sarg1, v) / 10000);
34310 float pct = perc / 100.0;
34311 // zprint("pct is: %f\n",pct);
34312 float temp_midi = 0;
34313 float temp_digi = 0;
34314 float temp_mus = 0;
34315 if (!(coreflags & FFCORE_SCRIPTED_MIDI_VOLUME))
34316 {
34317 // zprint("FFCORE_SCRIPTED_MIDI_VOLUME: wasn't set\n");
34318 temp_midi = do_getMIDI_volume();
34319 // zprint("temp_midi is %f\n", temp_midi);
34320 usr_midi_volume = do_getMIDI_volume();
34321 // zprint("usr_midi_volume stored as %d\n", usr_midi_volume);
34322 SetFFEngineFlag(FFCORE_SCRIPTED_MIDI_VOLUME, true);
34323 }
34324 else
34325 {
34326 temp_midi = (float)usr_midi_volume;
34327 }
34328 if (!(coreflags & FFCORE_SCRIPTED_DIGI_VOLUME))
34329 {
34330 temp_digi = do_getDIGI_volume();
34331 usr_digi_volume = do_getDIGI_volume();
34332 // zprint("usr_music_volume stored as %d\n", usr_digi_volume);
34333 SetFFEngineFlag(FFCORE_SCRIPTED_DIGI_VOLUME, true);
34334 }
34335 else
34336 {
34337 temp_digi = (float)usr_digi_volume;
34338 }
34339 if (!(coreflags & FFCORE_SCRIPTED_MUSIC_VOLUME))
34340 {
34341 temp_mus = do_getMusic_volume();
34342 usr_music_volume = do_getMusic_volume();
34343 // zprint("usr_music_volume stored as %d\n", usr_music_volume);
34344 SetFFEngineFlag(FFCORE_SCRIPTED_MUSIC_VOLUME, true);
34345 }
34346 else
34347 {
34348 temp_mus = (float)usr_music_volume;
34349 }
34350
34351 temp_midi *= pct;
34352 temp_digi *= pct;
34353 temp_mus *= pct;
34354 // zprint("temp_midi is: %f\n",temp_midi);
34355 // zprint("temp_digi is: %f\n",temp_digi);
34356 // zprint("temp_mus is: %f\n",temp_mus);
34357 do_setMIDI_volume((int32_t)temp_midi);
34358 do_setDIGI_volume((int32_t)temp_digi);
34359 do_setMusic_volume((int32_t)temp_mus);
34360 }
34361 else
34362 {
34363 int32_t perc = SH::get_arg(sarg1, v);
34364 FFCore.usr_music_volume = vbound(perc, 0, 10000 * 100);
34365
34366 if (zcmusic != NULL)
34367 {
34368 if (zcmusic->playing != ZCM_STOPPED)
34369 {
34370 int32_t temp_volume = emusic_volume;
34371 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
34372 temp_volume = (emusic_volume * FFCore.usr_music_volume) / 10000 / 100;
34373 temp_volume = (temp_volume * zcmusic->fadevolume) / 10000;
34374 zcmusic_play(zcmusic, temp_volume);
34375 return;
34376 }
34377 }
34378 else if (currmidi > -1)
34379 {
34380 jukebox(currmidi);
34381 master_volume(digi_volume, midi_volume);
34382 }
34383 }
34384 }
34385
34386 void FFScript::do_adjustsfxvolume(const bool v)
34387 {
34388 if (get_qr(qr_OLD_SCRIPT_VOLUME))
34389 {
34390 int32_t perc = (SH::get_arg(sarg1, v) / 10000);
34391 float pct = perc / 100.0;
34392 float temp_sfx = 0;
34393 if (!(coreflags & FFCORE_SCRIPTED_SFX_VOLUME))
34394 {
34395 temp_sfx = do_getSFX_volume();
34396 usr_sfx_volume = (int32_t)temp_sfx;
34397 // zprint("usr_sfx_volume stored as %d\n", usr_sfx_volume);
34398 SetFFEngineFlag(FFCORE_SCRIPTED_SFX_VOLUME, true);
34399 }
34400 else
34401 {
34402 temp_sfx = (float)usr_sfx_volume;
34403 }
34404 temp_sfx *= pct;
34405 do_setSFX_volume((int32_t)temp_sfx);
34406 }
34407 else
34408 {
34409 int32_t perc = SH::get_arg(sarg1, v);
34410 FFCore.usr_sfx_volume = vbound(perc, 0, 10000 * 100);
34411 }
34412 }
34413
34414
34415 63813 void do_midi(bool v)
34416 {
34417 63813 int32_t MIDI = SH::get_arg(sarg1, v) / 10000;
34418
34419
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 63776 times.
63813 if(MIDI == 0)
34420 37 music_stop();
34421 else
34422 63776 jukebox(MIDI + (ZC_MIDI_COUNT - 1));
34423 63813 }
34424
34425
34426 void stop_sfx(const bool v)
34427 {
34428 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34429 int32_t sfx = (int32_t)ID;
34430 if(BC::checkSFXID(ID, "Game->EndSound") != SH::_NoError)
34431 return;
34432 stop_sfx(sfx);
34433 }
34434
34435 void pause_sfx(const bool v)
34436 {
34437 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34438 int32_t sfx = (int32_t)ID;
34439 if(BC::checkSFXID(ID, "Game->PauseSound") != SH::_NoError)
34440 return;
34441 pause_sfx(sfx);
34442 }
34443
34444 void resume_sfx(const bool v)
34445 {
34446 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34447 int32_t sfx = (int32_t)ID;
34448 if(BC::checkSFXID(ID, "Game->ResumeSound") != SH::_NoError)
34449 return;
34450 resume_sfx(sfx);
34451 }
34452
34453
34454
34455 79 void do_enh_music(bool v)
34456 {
34457 79 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
34458 79 int32_t track = (SH::get_arg(sarg2, v) / 10000)-1;
34459
34460
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(arrayptr == 0)
34461 music_stop();
34462 else // Pointer to a string..
34463 {
34464 79 string filename_str;
34465 char filename_char[256];
34466 bool ret;
34467
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 ArrayH::getString(arrayptr, filename_str, 256);
34468 79 strncpy(filename_char, filename_str.c_str(), 255);
34469 79 filename_char[255]='\0';
34470
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 ret=try_zcmusic(filename_char, track, -1000);
34471
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 set_register(sarg2, ret ? 10000 : 0);
34472 79 }
34473 79 }
34474
34475 void do_enh_music_crossfade()
34476 {
34477 int32_t arrayptr = SH::read_stack(ri->sp + 5) / 10000;
34478 int32_t track = SH::read_stack(ri->sp + 4) / 10000;
34479 int32_t fadeoutframes = zc_max(SH::read_stack(ri->sp + 3) / 10000, 0);
34480 int32_t fadeinframes = zc_max(SH::read_stack(ri->sp + 2) / 10000, 0);
34481 int32_t fademiddleframes = SH::read_stack(ri->sp + 1) / 10000;
34482 int32_t startpos = SH::read_stack(ri->sp);
34483
34484 if (arrayptr == 0)
34485 {
34486 bool ret = FFCore.play_enh_music_crossfade(NULL, track, fadeoutframes, fadeinframes, fademiddleframes, startpos);
34487 ri->d[rEXP1] = ret ? 10000 : 0;
34488 }
34489 else
34490 {
34491 string filename_str;
34492 char filename_char[256];
34493 ArrayH::getString(arrayptr, filename_str, 256);
34494 strncpy(filename_char, filename_str.c_str(), 255);
34495 filename_char[255] = '\0';
34496 bool ret = FFCore.play_enh_music_crossfade(filename_char, track, fadeoutframes, fadeinframes, fademiddleframes, startpos, true);
34497 ri->d[rEXP1] = ret ? 10000 : 0;
34498 }
34499 }
34500
34501 bool FFScript::play_enh_music_crossfade(char* name, int32_t track, int32_t fadeinframes, int32_t fadeoutframes, int32_t fademiddleframes, int32_t startpos, bool revertonfail)
34502 {
34503 double fadeoutpct = 1.0;
34504 // If there was an old fade going, use that as a multiplier for the new fade out
34505 if (zcmixer->newtrack != NULL)
34506 {
34507 fadeoutpct = double(zcmixer->newtrack->fadevolume) / 10000.0;
34508 }
34509
34510 ZCMUSIC* oldold = zcmixer->oldtrack;
34511 bool ret = false;
34512
34513 if (name == NULL)
34514 {
34515 // Pass currently playing music off to the mixer
34516 zcmixer->oldtrack = zcmusic;
34517 // Do not play new music
34518 zcmusic = NULL;
34519 zcmixer->newtrack = NULL;
34520
34521 zcmixer->fadeinframes = fadeinframes;
34522 zcmixer->fadeinmaxframes = fadeinframes;
34523 zcmixer->fadeoutframes = zc_max(fadeoutframes * fadeoutpct, 1);
34524 zcmixer->fadeoutmaxframes = fadeoutframes;
34525 if (fademiddleframes < 0)
34526 {
34527 zcmixer->fadeindelay = 0;
34528 zcmixer->fadeoutdelay = -fademiddleframes;
34529 }
34530 else
34531 {
34532 zcmixer->fadeindelay = fademiddleframes;
34533 zcmixer->fadeoutdelay = 0;
34534 }
34535 if (zcmixer->oldtrack != NULL)
34536 zcmixer->oldtrack->fadevolume = 10000;
34537 if (zcmixer->newtrack != NULL)
34538 zcmixer->newtrack->fadevolume = 0;
34539 }
34540 else // Pointer to a string..
34541 {
34542 // Pass currently playing music to the mixer
34543 zcmixer->oldtrack = zcmusic;
34544 zcmusic = NULL;
34545 zcmixer->newtrack = NULL;
34546
34547 ret = try_zcmusic(name, track, -1000, fadeoutframes);
34548 // If new music was found
34549 if (ret)
34550 {
34551 // New music fades in
34552 if (zcmusic != NULL)
34553 zcmusic->fadevolume = 0;
34554
34555 zcmixer->newtrack = zcmusic;
34556 zcmixer->fadeinframes = fadeinframes;
34557 zcmixer->fadeinmaxframes = fadeinframes;
34558 zcmixer->fadeoutframes = zc_max(fadeoutframes * fadeoutpct, 1);
34559 zcmixer->fadeoutmaxframes = fadeoutframes;
34560 if (fademiddleframes < 0)
34561 {
34562 zcmixer->fadeindelay = 0;
34563 zcmixer->fadeoutdelay = -fademiddleframes;
34564 }
34565 else
34566 {
34567 zcmixer->fadeindelay = fademiddleframes;
34568 zcmixer->fadeoutdelay = 0;
34569 }
34570 if (startpos > 0)
34571 zcmusic_set_curpos(zcmixer->newtrack, startpos);
34572 if (zcmixer->oldtrack != NULL)
34573 zcmixer->oldtrack->fadevolume = 10000;
34574 if (zcmixer->newtrack != NULL)
34575 zcmixer->newtrack->fadevolume = 0;
34576 }
34577 else if(revertonfail)
34578 {
34579 // Switch back to the old music
34580 zcmusic = zcmixer->oldtrack;
34581 zcmixer->newtrack = NULL;
34582 zcmixer->oldtrack = NULL;
34583 }
34584 }
34585
34586 // If there was already an old track playing, stop it
34587 if (oldold != NULL)
34588 {
34589 // Don't allow it to null both tracks if running twice in a row
34590 if (zcmixer->newtrack == NULL && zcmixer->oldtrack == NULL)
34591 {
34592 zcmixer->oldtrack = oldold;
34593
34594 if (oldold->fadeoutframes > 0)
34595 {
34596 zcmixer->fadeoutframes = zc_max(oldold->fadeoutframes * fadeoutpct, 1);
34597 zcmixer->fadeoutmaxframes = oldold->fadeoutframes;
34598 if (zcmixer->oldtrack != NULL)
34599 zcmixer->oldtrack->fadevolume = 10000;
34600 oldold->fadeoutframes = 0;
34601 }
34602 }
34603 else
34604 {
34605 zcmusic_stop(oldold);
34606 zcmusic_unload_file(oldold);
34607 oldold = NULL;
34608 }
34609 }
34610
34611 return ret;
34612 }
34613
34614 bool FFScript::doing_dmap_enh_music(int32_t dm)
34615 {
34616 if (DMaps[dm].tmusic[0] != 0)
34617 {
34618 if (zcmusic != NULL)
34619 {
34620 if (strcmp(zcmusic->filename, DMaps[dm].tmusic) == 0)
34621 {
34622 switch (zcmusic_get_type(zcmusic))
34623 {
34624 case ZCMF_OGG:
34625 case ZCMF_MP3:
34626 return true;
34627 case ZCMF_DUH:
34628 case ZCMF_GME:
34629 if (zcmusic->track == DMaps[dm].tmusictrack)
34630 {
34631 return true;
34632 }
34633 }
34634 }
34635 }
34636 }
34637 return false;
34638 }
34639
34640 17605 bool FFScript::can_dmap_change_music(int32_t dm)
34641 {
34642
1/4
✓ Branch 0 taken 17605 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17605 switch (music_update_cond)
34643 {
34644 case MUSIC_UPDATE_SCREEN:
34645 17605 return true;
34646 case MUSIC_UPDATE_DMAP:
34647 return dm != -1 && dm != currdmap;
34648 case MUSIC_UPDATE_LEVEL:
34649 return dm != -1 && DMaps[dm].level != DMaps[currdmap].level;
34650 }
34651 return false;
34652 17605 }
34653
34654 void FFScript::do_set_music_position(const bool v)
34655 {
34656 int32_t newposition = SH::get_arg(sarg1, v);
34657
34658 set_zcmusicpos(newposition);
34659 }
34660
34661 void FFScript::do_get_music_position()
34662 {
34663 int32_t pos = replay_get_state(ReplayStateType::MusicPosition, [](){
34664 return zcmusic_get_curpos(zcmusic);
34665 });
34666 set_register(sarg1, pos);
34667 }
34668
34669 void FFScript::do_set_music_speed(const bool v)
34670 {
34671 int32_t newspeed = SH::get_arg(sarg1, v);
34672 set_zcmusicspeed(newspeed);
34673 }
34674
34675 void FFScript::do_get_music_length()
34676 {
34677 int32_t len = get_zcmusiclen();
34678 set_register(sarg1, len);
34679 }
34680
34681 void FFScript::do_set_music_loop()
34682 {
34683 double start = (get_register(sarg1) / 10000);
34684 double end = (get_register(sarg2) / 10000);
34685
34686 set_zcmusicloop(start, end);
34687 }
34688
34689 100 void do_get_enh_music_filename(const bool v)
34690 {
34691 100 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34692 100 int32_t arrayptr = get_register(sarg2) / 10000;
34693
34694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(BC::checkDMapID(ID, "Game->GetDMapMusicFilename") != SH::_NoError)
34695 return;
34696
34697
3/6
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
100 if(ArrayH::setArray(arrayptr, string(DMaps[ID].tmusic)) == SH::_Overflow)
34698 Z_scripterrlog("Array supplied to 'Game->GetDMapMusicFilename' not large enough\n");
34699 100 }
34700
34701 5 void do_get_enh_music_track(const bool v)
34702 {
34703 5 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34704
34705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(BC::checkDMapID(ID, "Game->GetDMapMusicTrack") != SH::_NoError)
34706 return;
34707
34708 5 set_register(sarg1, (DMaps[ID].tmusictrack+1)*10000);
34709 5 }
34710
34711 3750 void do_set_dmap_enh_music(const bool v)
34712 {
34713 3750 int32_t ID = SH::read_stack(ri->sp + 2) / 10000;
34714 3750 int32_t arrayptr = SH::read_stack(ri->sp + 1) / 10000;
34715 3750 int32_t track = (SH::read_stack(ri->sp + 0) / 10000)-1;
34716 3750 string filename_str;
34717
34718
2/4
✓ Branch 0 taken 3750 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3750 times.
✗ Branch 3 not taken.
3750 if(BC::checkDMapID(ID, "Game->SetDMapEnhancedMusic") != SH::_NoError)
34719 return;
34720
34721
1/2
✓ Branch 0 taken 3750 times.
✗ Branch 1 not taken.
3750 ArrayH::getString(arrayptr, filename_str, 56);
34722 3750 strncpy(DMaps[ID].tmusic, filename_str.c_str(), 55);
34723 3750 DMaps[ID].tmusic[55]='\0';
34724 3750 DMaps[ID].tmusictrack=track;
34725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3750 times.
3750 }
34726
34727
34728
34729
34730
34731
34732 ///----------------------------------------------------------------------------------------------------//
34733 //Array & string related
34734
34735 294114413 void do_arraysize()
34736 {
34737 294114413 int32_t arrayptr = get_register(sarg1) / 10000;
34738 294114413 ri->d[rEXP1] = ArrayH::getSize(arrayptr) * 10000;
34739 294114413 }
34740
34741 void do_tobyte()
34742 {
34743 int32_t b1 = get_register(sarg1) / 10000;
34744 byte b2 = b1;
34745 set_register(sarg1, b2 * 10000);
34746 }
34747
34748 void do_tosignedbyte()
34749 {
34750 int32_t b1 = get_register(sarg1) / 10000;
34751 signed char b2 = b1;
34752 set_register(sarg1, b2 * 10000);
34753 }
34754
34755 void do_tointeger()
34756 {
34757 int32_t b1 = get_register(sarg1) / 10000;
34758 set_register(sarg1, b1 * 10000);
34759 }
34760
34761 void do_floor()
34762 {
34763 double b1 = get_register(sarg1) / 10000.0;
34764 int32_t b2 = floor(b1);
34765 set_register(sarg1, b2 * 10000);
34766 }
34767
34768 void do_ceiling()
34769 {
34770 double b1 = get_register(sarg1) / 10000.0;
34771 int32_t b2 = ceil(b1);
34772 set_register(sarg1, b2 * 10000);
34773 }
34774
34775 void do_toword()
34776 {
34777 int32_t b1 = get_register(sarg1) / 10000;
34778 word b2 = b1;
34779 set_register(sarg1, b2 * 10000);
34780 }
34781
34782 void do_toshort()
34783 {
34784 int32_t b1 = get_register(sarg1) / 10000;
34785 int16_t b2 = b1;
34786 set_register(sarg1, b2 * 10000);
34787 }
34788
34789 10 void do_getsavename()
34790 {
34791 10 int32_t arrayptr = get_register(sarg1) / 10000;
34792
34793
3/6
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 if(ArrayH::setArray(arrayptr, string(game->get_name())) == SH::_Overflow)
34794 Z_scripterrlog("Array supplied to 'Game->GetSaveName' not large enough\n");
34795 10 }
34796
34797 void do_setsavename()
34798 {
34799 int32_t arrayptr = get_register(sarg1) / 10000;
34800
34801 string str;
34802 ArrayH::getString(arrayptr, str);
34803 byte j;
34804
34805 for(j = 0; str[j] != '\0'; j++)
34806 {
34807 if(j >= 8)
34808 {
34809 Z_scripterrlog("String supplied to 'Game->GetSaveName' too large\n");
34810 return;
34811 }
34812 }
34813
34814 game->set_name(str);
34815 }
34816
34817 3666 void do_getmessage(const bool v)
34818 {
34819 3666 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34820 3666 int32_t arrayptr = get_register(sarg2) / 10000;
34821
34822
1/2
✓ Branch 0 taken 3666 times.
✗ Branch 1 not taken.
3666 if(BC::checkMessage(ID, "Game->GetMessage") != SH::_NoError)
34823 return;
34824
34825
2/2
✓ Branch 0 taken 3618 times.
✓ Branch 1 taken 48 times.
3666 if(ArrayH::setArray(arrayptr, MsgStrings[ID].s) == SH::_Overflow)
34826 48 Z_scripterrlog("Array supplied to 'Game->GetMessage' not large enough\n");
34827 3666 }
34828
34829
34830
34831 void do_setmessage(const bool v)
34832 {
34833 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34834 int32_t arrayptr = get_register(sarg2) / 10000;
34835
34836 if(BC::checkMessage(ID, "Game->SetMessage") != SH::_NoError)
34837 return;
34838
34839 ArrayH::getString(arrayptr, MsgStrings[ID].s, MSG_NEW_SIZE);
34840 }
34841
34842
34843 void do_getdmapname(const bool v)
34844 {
34845 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34846 int32_t arrayptr = get_register(sarg2) / 10000;
34847
34848 if(BC::checkDMapID(ID, "Game->GetDMapName") != SH::_NoError)
34849 return;
34850
34851 if(ArrayH::setArray(arrayptr, string(DMaps[ID].name)) == SH::_Overflow)
34852 Z_scripterrlog("Array supplied to 'Game->GetDMapName' not large enough\n");
34853 }
34854
34855 void do_setdmapname(const bool v)
34856 {
34857 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34858 int32_t arrayptr = get_register(sarg2) / 10000;
34859
34860 string filename_str;
34861
34862 if(BC::checkDMapID(ID, "Game->Game->SetDMapName") != SH::_NoError)
34863 return;
34864
34865 ArrayH::getString(arrayptr, filename_str, 22);
34866 strncpy(DMaps[ID].name, filename_str.c_str(), 21);
34867 DMaps[ID].name[20]='\0';
34868 }
34869
34870 701 void do_getdmaptitle(const bool v)
34871 {
34872 701 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34873 701 int32_t arrayptr = get_register(sarg2) / 10000;
34874
34875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 701 times.
701 if(BC::checkDMapID(ID, "Game->GetDMapTitle") != SH::_NoError)
34876 return;
34877
34878
1/2
✓ Branch 0 taken 701 times.
✗ Branch 1 not taken.
701 if (!get_qr(qr_OLD_DMAP_INTRO_STRINGS))
34879 {
34880 ArrayManager am(arrayptr);
34881 am.resize(DMaps[ID].title.size() + 1);
34882 }
34883
2/4
✓ Branch 0 taken 701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 701 times.
✗ Branch 3 not taken.
701 if(ArrayH::setArray(arrayptr, string(DMaps[ID].title)) == SH::_Overflow)
34884 Z_scripterrlog("Array supplied to 'Game->GetDMapTitle' not large enough\n");
34885 701 }
34886
34887
34888 void do_setdmaptitle(const bool v)
34889 {
34890 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34891 int32_t arrayptr = get_register(sarg2) / 10000;
34892 string filename_str;
34893
34894 if(BC::checkDMapID(ID, "Game->Game->SetDMapTitle") != SH::_NoError)
34895 return;
34896
34897 if (get_qr(qr_OLD_DMAP_INTRO_STRINGS))
34898 {
34899 char namestr[21];
34900 ArrayH::getString(arrayptr, filename_str, 21);
34901 strncpy(namestr, filename_str.c_str(), 20);
34902 namestr[20] = '\0';
34903 DMaps[ID].title.assign(namestr);
34904 }
34905 else
34906 {
34907 ArrayH::getString(arrayptr, filename_str, ArrayH::getSize(arrayptr));
34908 DMaps[ID].title = filename_str;
34909 }
34910 }
34911
34912 void do_getdmapintro(const bool v)
34913 {
34914 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34915 int32_t arrayptr = get_register(sarg2) / 10000;
34916
34917 if(BC::checkDMapID(ID, "Game->GetDMapIntro") != SH::_NoError)
34918 return;
34919
34920 if(ArrayH::setArray(arrayptr, string(DMaps[ID].intro)) == SH::_Overflow)
34921 Z_scripterrlog("Array supplied to 'Game->GetDMapIntro' not large enough\n");
34922 }
34923
34924
34925 void do_setdmapintro(const bool v)
34926 {
34927 int32_t ID = SH::get_arg(sarg1, v) / 10000;
34928 int32_t arrayptr = get_register(sarg2) / 10000;
34929 string filename_str;
34930
34931 if(BC::checkDMapID(ID, "Game->Game->SetDMapIntro") != SH::_NoError)
34932 return;
34933
34934 ArrayH::getString(arrayptr, filename_str, 73);
34935 strncpy(DMaps[ID].intro, filename_str.c_str(), 72);
34936 DMaps[ID].intro[72]='\0';
34937 }
34938
34939 //Set npc and item names t.b.a. -Z
34940
34941 2691 void do_getitemname()
34942 {
34943 2691 int32_t arrayptr = get_register(sarg1) / 10000;
34944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2691 times.
2691 if(unsigned(ri->idata) >= MAXITEMS)
34945 {
34946 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
34947 return;
34948 }
34949
34950
3/6
✓ Branch 0 taken 2691 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2691 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2691 times.
✗ Branch 5 not taken.
2691 if(ArrayH::setArray(arrayptr, item_string[ri->idata]) == SH::_Overflow)
34951 Z_scripterrlog("Array supplied to 'itemdata->GetName' not large enough\n");
34952 2691 }
34953
34954 void do_getnpcname()
34955 {
34956 int32_t arrayptr = get_register(sarg1) / 10000;
34957
34958 if(GuyH::loadNPC(ri->guyref, "npc->GetName") != SH::_NoError)
34959 return;
34960
34961 word ID = (GuyH::getNPC()->id & 0xFFF);
34962
34963 if(ArrayH::setArray(arrayptr, guy_string[ID]) == SH::_Overflow)
34964 Z_scripterrlog("Array supplied to 'npc->GetName' not large enough\n");
34965 }
34966
34967 //npcdata->GetName
34968 void FFScript::do_getnpcdata_getname()
34969 {
34970 int32_t arrayptr = get_register(sarg1) / 10000;
34971 int32_t npc_id = ri->npcdataref;
34972 if((unsigned)npc_id > 511)
34973 {
34974 Z_scripterrlog("Invalid npc ID (%d) passed to npcdata->GetName().\n", npc_id);
34975 return;
34976 }
34977
34978 if(ArrayH::setArray(arrayptr, guy_string[npc_id]) == SH::_Overflow)
34979 Z_scripterrlog("Array supplied to 'npcdata->GetName()' not large enough\n");
34980 }
34981
34982 227724 void do_getffcscript()
34983 {
34984 227724 int32_t arrayptr = get_register(sarg1) / 10000;
34985 227724 string name;
34986 227724 int32_t num=-1;
34987
1/2
✓ Branch 0 taken 227724 times.
✗ Branch 1 not taken.
227724 ArrayH::getString(arrayptr, name, 256); // What's the limit on name length?
34988
34989
2/2
✓ Branch 0 taken 116286088 times.
✓ Branch 1 taken 227034 times.
116513122 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
34990 {
34991
3/4
✓ Branch 0 taken 116286088 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116285398 times.
✓ Branch 3 taken 690 times.
116286088 if(strcmp(name.c_str(), ffcmap[i].scriptname.c_str())==0)
34992 {
34993 690 num=i+1;
34994 690 break;
34995 }
34996 116285398 }
34997
34998
1/2
✓ Branch 0 taken 227724 times.
✗ Branch 1 not taken.
227724 set_register(sarg1, num * 10000);
34999 227724 }
35000
35001 void do_npc_hero_in_range()
35002 {
35003 int32_t dist = get_register(sarg1) / 10000;
35004 if(GuyH::loadNPC(ri->guyref, "npc->LinedUp()") == SH::_NoError)
35005 {
35006 bool in_range = GuyH::getNPC()->HeroInRange(dist);
35007 set_register(sarg1, 0);
35008 }
35009 else set_register(sarg1, 0);
35010 }
35011
35012 80 void do_getitemscript()
35013 {
35014 80 int32_t arrayptr = get_register(sarg1) / 10000;
35015 80 string name;
35016 80 int32_t num=-1;
35017
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 ArrayH::getString(arrayptr, name, 256); // What's the limit on name length?
35018
35019
1/2
✓ Branch 0 taken 2360 times.
✗ Branch 1 not taken.
2360 for(int32_t i=0; i<512; i++)
35020 {
35021
3/4
✓ Branch 0 taken 2360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2280 times.
✓ Branch 3 taken 80 times.
2360 if(strcmp(name.c_str(), itemmap[i].scriptname.c_str())==0)
35022 {
35023 80 num=i+1;
35024 80 break;
35025 }
35026 2280 }
35027
35028
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 set_register(sarg1, num * 10000);
35029 80 }
35030
35031 ///----------------------------------------------------------------------------------------------------//
35032 //Tile Manipulation
35033
35034 16962076 void do_copytile(const bool v, const bool v2)
35035 {
35036 16962076 int32_t tile = SH::get_arg(sarg1, v) / 10000;
35037 16962076 int32_t tile2 = SH::get_arg(sarg2, v2) / 10000;
35038
35039 16962076 copy_tile(newtilebuf, tile, tile2, false);
35040 16962076 }
35041
35042 int32_t FFScript::IsBlankTile(int32_t i)
35043 {
35044 if( ((unsigned)i) > NEWMAXTILES )
35045 {
35046 Z_scripterrlog("Invalid tile ID (%d) passed to Graphics->IsBlankTile[]\n");
35047 return -1;
35048 }
35049
35050 byte *tilestart=newtilebuf[i].data;
35051 qword *di=(qword*)tilestart;
35052 int32_t parts=tilesize(newtilebuf[i].format)>>3;
35053
35054 for(int32_t j=0; j<parts; ++j, ++di)
35055 {
35056 if(*di!=0)
35057 {
35058 return 0;
35059 }
35060 }
35061
35062 return 1;
35063 }
35064
35065 void do_swaptile(const bool v, const bool v2)
35066 {
35067 int32_t tile = SH::get_arg(sarg1, v) / 10000;
35068 int32_t tile2 = SH::get_arg(sarg2, v2) / 10000;
35069
35070 copy_tile(newtilebuf, tile, tile2, true);
35071 }
35072
35073 57032 void do_overlaytile(const bool v, const bool v2)
35074 {
35075 57032 int32_t tile = SH::get_arg(sarg1, v) / 10000;
35076 57032 int32_t tile2 = SH::get_arg(sarg2, v2) / 10000;
35077
35078
2/4
✓ Branch 0 taken 57032 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57032 times.
✗ Branch 3 not taken.
57032 if(BC::checkTile(tile, "OverlayTile") != SH::_NoError ||
35079 57032 BC::checkTile(tile2, "OverlayTile") != SH::_NoError)
35080 return;
35081
35082 //Could add an arg for the CSet or something instead of just passing 0, currently only 8-bit is supported
35083 57032 overlay_tile(newtilebuf, tile, tile2, 0, false);
35084 57032 }
35085
35086 void do_fliprotatetile(const bool v, const bool v2)
35087 {
35088 int32_t tile = SH::get_arg(sarg1, v) / 10000;
35089 int32_t tile2 = SH::get_arg(sarg2, v2) / 10000;
35090
35091 if(BC::checkTile(tile, "FlipRotateTile") != SH::_NoError ||
35092 BC::checkTile(tile2, "FlipRotateTile") != SH::_NoError)
35093 return;
35094
35095 //fliprotatetile
35096 }
35097
35098 void do_settilepixel(const bool v)
35099 {
35100 int32_t tile = SH::get_arg(sarg1, v) / 10000;
35101
35102 if(BC::checkTile(tile, "SetTilePixel") != SH::_NoError)
35103 return;
35104
35105 //settilepixel
35106 }
35107
35108 void do_gettilepixel(const bool v)
35109 {
35110 int32_t tile = SH::get_arg(sarg1, v) / 10000;
35111
35112 if(BC::checkTile(tile, "GetTilePixel") != SH::_NoError)
35113 return;
35114
35115 //gettilepixel
35116 }
35117
35118 void do_shifttile(const bool v, const bool v2)
35119 {
35120 int32_t tile = SH::get_arg(sarg1, v) / 10000;
35121 int32_t tile2 = SH::get_arg(sarg2, v2) / 10000;
35122
35123 if(BC::checkTile(tile, "ShiftTile") != SH::_NoError ||
35124 BC::checkTile(tile2, "ShiftTile") != SH::_NoError)
35125 return;
35126
35127 //shifttile
35128 }
35129
35130 void do_cleartile(const bool v)
35131 {
35132 int32_t tile = SH::get_arg(sarg1, v) / 10000;
35133
35134 if(BC::checkTile(tile, "ClearTile") != SH::_NoError)
35135 return;
35136
35137 reset_tile(newtilebuf, tile, newtilebuf[tile].format);
35138 }
35139
35140 2564 void do_combotile(const bool v)
35141 {
35142 2564 int32_t combo = SH::get_arg(sarg2, v) / 10000;
35143
35144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2564 times.
2564 if(BC::checkCombo(combo, "Game->ComboTile") != SH::_NoError)
35145 return;
35146
35147 2564 set_register(sarg1, combobuf[combo].tile * 10000);
35148 2564 }
35149
35150 94605932 void do_readpod(const bool v)
35151 {
35152 94605932 int32_t indx = SH::get_arg(sarg2, v) / 10000;
35153 94605932 int32_t val = ArrayH::getElement(ri->d[rINDEX] / 10000, indx, can_neg_array);
35154 94605932 set_register(sarg1, val);
35155 94605932 }
35156 63178714 void do_writepod(const bool v1, const bool v2)
35157 {
35158 63178714 int32_t indx = SH::get_arg(sarg1, v1) / 10000;
35159 63178714 int32_t val = SH::get_arg(sarg2, v2);
35160 63178714 ArrayH::setElement(ri->d[rINDEX] / 10000, indx, val, can_neg_array);
35161 63178714 }
35162 241209 void do_writepodstr()
35163 {
35164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 241209 times.
241209 if(!sargstr) return;
35165 241209 auto ptr = get_register(sarg1) / 10000;
35166 241209 ArrayH::setArray(ptr, *sargstr);
35167 241209 }
35168 333 void do_writepodarr()
35169 {
35170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 333 times.
333 if(!sargvec) return;
35171 333 auto ptr = get_register(sarg1) / 10000;
35172 333 ArrayH::setArray(ptr, sargvec->size(), sargvec->data(), false);
35173 333 }
35174 int32_t get_object_arr(size_t sz)
35175 {
35176 if(sz > 214748) return 0;
35177 int32_t free_ptr = 1;
35178 auto it = objectRAM.begin();
35179 if(it != objectRAM.end())
35180 {
35181 if(it->first == 1)
35182 {
35183 for(free_ptr = 2; ; ++free_ptr)
35184 {
35185 if(objectRAM.find(free_ptr) == objectRAM.end())
35186 break;
35187 }
35188 }
35189 }
35190 ZScriptArray arr;
35191 arr.Resize(sz);
35192 arr.setValid(true);
35193 objectRAM[free_ptr] = arr;
35194 // auto res = objectRAM.emplace(free_ptr);
35195 // ZScriptArray& arr = res.first->second;
35196 // arr.Resize(sz);
35197
35198 return -free_ptr;
35199 }
35200 void destroy_object_arr(int32_t ptr)
35201 {
35202 if(ptr < 0)
35203 {
35204 auto it = objectRAM.find(-ptr);
35205 if(it != objectRAM.end())
35206 objectRAM.erase(it);
35207 }
35208 }
35209 void do_constructclass(ScriptType type, word script, int32_t i)
35210 {
35211 if(!sargvec) return;
35212
35213 size_t num_vars = sargvec->at(0);
35214 size_t total_vars = num_vars + sargvec->size()-1;
35215 auto destr_pc = ri->d[rEXP1];
35216 dword objref = FFCore.get_free_object(false);
35217
35218 if(user_object* obj = checkObject(objref, true))
35219 {
35220 obj->own(type, i);
35221 obj->owned_vars = num_vars;
35222 for(size_t q = 0; q < total_vars; ++q)
35223 {
35224 if(q < num_vars)
35225 {
35226 obj->data.push_back(0);
35227 }
35228 else
35229 {
35230 size_t sz = sargvec->at(q-num_vars+1);
35231 if(auto id = get_object_arr(sz))
35232 obj->data.push_back(10000*id);
35233 else obj->data.push_back(0); //nullptr
35234 }
35235 }
35236 set_register(sarg1, objref);
35237 ri->thiskey = objref;
35238 obj->prep(destr_pc,type,script,i);
35239 }
35240 else set_register(sarg1, 0);
35241 }
35242
35243 void do_readclass()
35244 {
35245 dword objref = get_register(sarg1);
35246 ri->d[rEXP1] = 0;
35247 int32_t ind = sarg2;
35248 if(user_object* obj = checkObject(objref))
35249 {
35250 if(unsigned(ind) >= obj->data.size())
35251 {
35252 Z_scripterrlog("Script tried to read position '%d' out of bounds on a '%d' size object (%d).", ind, obj->data.size(), objref);
35253 }
35254 else
35255 {
35256 ri->d[rEXP1] = obj->data.at(ind);
35257 }
35258 }
35259 }
35260 void do_writeclass()
35261 {
35262 dword objref = get_register(sarg1);
35263 int32_t ind = sarg2;
35264 if(user_object* obj = checkObject(objref))
35265 {
35266 if(unsigned(ind) >= obj->data.size())
35267 {
35268 Z_scripterrlog("Script tried to write position '%d' out of bounds on a '%d' size object (%d).", ind, obj->data.size(), objref);
35269 }
35270 else
35271 {
35272 obj->data[ind] = ri->d[rEXP1];
35273 }
35274 }
35275 }
35276 void do_freeclass()
35277 {
35278 dword objref = get_register(sarg1);
35279 if(user_object* obj = checkObject(objref, true))
35280 {
35281 obj->clear();
35282 }
35283 ri->d[rEXP1] = 0;
35284 }
35285
35286 bool zasm_advance()
35287 {
35288 if( key[KEY_INSERT] )
35289 {
35290 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
35291 {
35292 if(key[KEY_LCONTROL] || key[KEY_RCONTROL])
35293 {
35294 FFCore.zasm_break_mode = ZASM_BREAK_SKIP_SCRIPT;
35295 }
35296 else FFCore.zasm_break_mode = ZASM_BREAK_ADVANCE_SCRIPT;
35297 }
35298 else if(key[KEY_ALT] || key[KEY_ALTGR])
35299 {
35300 if(key[KEY_LCONTROL] || key[KEY_RCONTROL])
35301 {
35302 FFCore.zasm_break_mode = ZASM_BREAK_SKIP;
35303 }
35304 else FFCore.zasm_break_mode = ZASM_BREAK_NONE;
35305 }
35306 else if(key[KEY_LCONTROL] || key[KEY_RCONTROL])
35307 {
35308 FFCore.ZASMPrint(false); //Close debugger
35309 FFCore.zasm_break_mode = ZASM_BREAK_NONE;
35310 }
35311 return true;
35312 }
35313 if(!zasm_debugger)
35314 {
35315 FFCore.zasm_break_mode = ZASM_BREAK_NONE;
35316 return true;
35317 }
35318 return false;
35319 }
35320
35321 int32_t get_own_i(ScriptType type)
35322 {
35323 switch(type)
35324 {
35325 case ScriptType::Lwpn:
35326 return ri->lwpn;
35327 case ScriptType::Ewpn:
35328 return ri->ewpn;
35329 case ScriptType::ItemSprite:
35330 return ri->itemref;
35331 case ScriptType::NPC:
35332 return ri->guyref;
35333 case ScriptType::FFC:
35334 return ri->ffcref;
35335 }
35336 return 0;
35337 }
35338
35339 portal* loadportal(savedportal& p);
35340 ///----------------------------------------------------------------------------------------------------//
35341 // Run the script //
35342 ///----------------------------------------------------------------------------------------------------//
35343
35344
35345 10309284 int32_t run_script(ScriptType type, const word script, const int32_t i)
35346 {
35347
2/4
✓ Branch 0 taken 10309284 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10309284 times.
10309284 if(Quit==qRESET || Quit==qEXIT) // In case an earlier script hung
35348 return RUNSCRIPT_ERROR;
35349
35350
4/4
✓ Branch 0 taken 6419808 times.
✓ Branch 1 taken 3889476 times.
✓ Branch 2 taken 641558 times.
✓ Branch 3 taken 5778250 times.
10309284 if(type != ScriptType::Global && !script) return RUNSCRIPT_OK; //Safeguard against running null scripts
35351
35352 9667726 combopos_modified = -1;
35353 9667726 curScriptType=type;
35354 9667726 curScriptNum=script;
35355 9667726 curScriptIndex=i;
35356 //numInstructions=0; //DON'T CLEAR THIS OR IT CAN HARDLOCK! -Em
35357
35358
2/4
✓ Branch 0 taken 9667726 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9667726 times.
9667726 if (!(type >= ScriptType::First && type <= ScriptType::Last))
35359 {
35360 al_trace("Invalid script type: %d\n", (int)type);
35361 return RUNSCRIPT_ERROR;
35362 }
35363
35364 9667726 bool got_initialized = false;
35365
6/8
✓ Branch 0 taken 8923341 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 191687 times.
✓ Branch 4 taken 104554 times.
✓ Branch 5 taken 2517 times.
✓ Branch 6 taken 444085 times.
✓ Branch 7 taken 1542 times.
9667726 switch(type)
35366 {
35367 case ScriptType::FFC:
35368 case ScriptType::Global:
35369 case ScriptType::Player:
35370 case ScriptType::DMap:
35371 case ScriptType::OnMap:
35372 case ScriptType::ScriptedActiveSubscreen:
35373 case ScriptType::ScriptedPassiveSubscreen:
35374 case ScriptType::EngineSubscreen:
35375 case ScriptType::Screen:
35376 case ScriptType::Combo:
35377 case ScriptType::Item:
35378 {
35379 // TODO: finish refactoring the other script types.
35380 8923341 got_initialized = set_current_script_engine_data(type, script, i);
35381 }
35382 8923341 break;
35383
35384 case ScriptType::NPC:
35385 {
35386 int32_t npc_index = GuyH::getNPCIndex(i);
35387 enemy *w = (enemy*)guys.spr(npc_index);
35388 ri = &(w->scrmem->scriptData);
35389 curscript = guyscripts[w->script];
35390 stack = &(w->scrmem->stack);
35391 ri->guyref = i;
35392
35393 if (!w->initialised)
35394 {
35395 got_initialized = true;
35396 for ( int32_t q = 0; q < 8; q++ )
35397 {
35398 ri->d[q] = w->initD[q];
35399 }
35400 w->initialised = 1;
35401 }
35402 }
35403 break;
35404
35405 case ScriptType::Lwpn:
35406 {
35407 191687 int32_t lwpn_index = LwpnH::getLWeaponIndex(i);
35408 191687 weapon *w = (weapon*)Lwpns.spr(lwpn_index);
35409 191687 ri = &(w->scrmem->scriptData);
35410 191687 curscript = lwpnscripts[w->weaponscript];
35411 191687 stack = &(w->scrmem->stack);
35412 191687 ri->lwpn = i;
35413
35414
2/2
✓ Branch 0 taken 130423 times.
✓ Branch 1 taken 61264 times.
191687 if (!w->initialised)
35415 {
35416 61264 got_initialized = true;
35417
2/2
✓ Branch 0 taken 490112 times.
✓ Branch 1 taken 61264 times.
551376 for ( int32_t q = 0; q < 8; q++ )
35418 {
35419 490112 ri->d[q] = w->weap_initd[q]; //w->initiald[q];
35420 490112 }
35421 61264 w->initialised = 1;
35422 61264 }
35423 }
35424 191687 break;
35425
35426 case ScriptType::Ewpn:
35427 {
35428 104554 int32_t ewpn_index = EwpnH::getEWeaponIndex(i);
35429 104554 weapon *w = (weapon*)Ewpns.spr(ewpn_index);
35430 104554 ri = &(w->scrmem->scriptData);
35431 104554 curscript = ewpnscripts[w->weaponscript];
35432 104554 stack = &(w->scrmem->stack);
35433 104554 ri->ewpn = i;
35434
35435
2/2
✓ Branch 0 taken 103279 times.
✓ Branch 1 taken 1275 times.
104554 if (!w->initialised)
35436 {
35437 1275 got_initialized = true;
35438
2/2
✓ Branch 0 taken 10200 times.
✓ Branch 1 taken 1275 times.
11475 for ( int32_t q = 0; q < 8; q++ )
35439 {
35440 10200 ri->d[q] = w->weap_initd[q];
35441 10200 }
35442 1275 w->initialised = 1;
35443 1275 }
35444 }
35445 104554 break;
35446
35447 case ScriptType::ItemSprite:
35448 {
35449 2517 int32_t the_index = ItemH::getItemIndex(i);
35450 2517 item *w = (item*)items.spr(the_index);
35451 2517 ri = &(w->scrmem->scriptData);
35452 2517 curscript = itemspritescripts[w->script];
35453 2517 stack = &(w->scrmem->stack);
35454 2517 ri->itemref = i;
35455
35456
2/2
✓ Branch 0 taken 2435 times.
✓ Branch 1 taken 82 times.
2517 if (!w->initialised)
35457 {
35458 82 got_initialized = true;
35459
2/2
✓ Branch 0 taken 656 times.
✓ Branch 1 taken 82 times.
738 for ( int32_t q = 0; q < 8; q++ )
35460 {
35461 656 ri->d[q] = w->initD[q];
35462 656 }
35463 82 w->initialised = 1;
35464 82 }
35465 }
35466 2517 break;
35467
35468 case ScriptType::Generic:
35469 {
35470 444085 user_genscript& scr = user_scripts[script];
35471 444085 stack = &scr.stack;
35472 444085 ri = &scr.ri;
35473 444085 ri->genericdataref = script;
35474 444085 curscript = genericscripts[script];
35475 444085 scr.waitevent = false;
35476
2/2
✓ Branch 0 taken 443736 times.
✓ Branch 1 taken 349 times.
444085 if(!scr.initialized)
35477 {
35478 349 got_initialized = true;
35479 349 scr.initialized = true;
35480 349 memcpy(ri->d, scr.initd, 8 * sizeof(int32_t));
35481 349 }
35482 }
35483 444085 break;
35484
35485 case ScriptType::GenericFrozen:
35486 {
35487 1542 ri = genericActiveData.back();
35488 1542 ri->genericdataref = script;
35489 1542 curscript = genericscripts[script];
35490 1542 stack = generic_active_stack.back();
35491
2/2
✓ Branch 0 taken 1532 times.
✓ Branch 1 taken 10 times.
1542 if(!gen_active_initialized)
35492 {
35493 10 got_initialized = true;
35494 10 gen_active_initialized = true;
35495 10 memcpy(ri->d, user_scripts[script].initd, 8 * sizeof(int32_t));
35496 10 }
35497 }
35498 1542 break;
35499
35500 default:
35501 {
35502 al_trace("No other scripts are currently supported\n");
35503 return RUNSCRIPT_ERROR;
35504 }
35505 }
35506
35507 // Because qst.cpp likes to write script_data without setting this.
35508 9667726 curscript->meta.script_type = type;
35509
35510 // No need to do anything if the script is not valid.
35511 // An example of this is found in `playground.qst` player scripts, which have scripts with
35512 // a single 0xFFFF command.
35513 // Can't actually do this because we must unset `doscript` via the `scommand == 0xFFFF` handling in run_script_int.
35514 // Otherwise can get freeze, like in ending.cpp
35515 // if (!curscript->valid())
35516 // return RUNSCRIPT_OK;
35517
35518 9667726 script_funcrun = false;
35519
35520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9667726 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9667726 if (DEBUG_PRINT_ZASM && !seen_scripts.contains(curscript->debug_id))
35521 {
35522 seen_scripts.insert(curscript->debug_id);
35523 ScriptDebugHandle h(ScriptDebugHandle::OutputSplit::ByScript, curscript);
35524 h.print_zasm(curScriptNum, curScriptIndex);
35525 }
35526
35527 9667726 JittedScriptHandle* jitted_script = nullptr;
35528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9667726 times.
9667726 if (jit_is_enabled())
35529 {
35530 9667726 auto it = jitted_scripts.find({curscript, ri});
35531
2/2
✓ Branch 0 taken 11018 times.
✓ Branch 1 taken 9656708 times.
9667726 if (it == jitted_scripts.end())
35532 {
35533 11018 jitted_scripts[{curscript, ri}] = jitted_script = jit_create_script_handle(curscript, ri);
35534 11018 }
35535 else
35536 {
35537 9656708 jitted_script = it->second;
35538 }
35539 9667726 }
35540
35541 9667726 runtime_script_debug_handle = nullptr;
35542
1/2
✓ Branch 0 taken 9667726 times.
✗ Branch 1 not taken.
9667726 if (script_debug_is_runtime_debugging())
35543 {
35544 if (!script_debug_handles.contains(curscript->debug_id))
35545 {
35546 script_debug_handles.emplace(curscript->debug_id, ScriptDebugHandle(ScriptDebugHandle::OutputSplit::ByFrame, curscript));
35547 }
35548 runtime_script_debug_handle = &script_debug_handles.at(curscript->debug_id);
35549 runtime_script_debug_handle->update_file();
35550 runtime_script_debug_handle->print(fmt::format("\n=== running script id: {} name: {} type: {} i: {} script: {}\n", curscript->debug_id, curscript->meta.script_name, ScriptTypeToString(type), i, script).c_str());
35551 }
35552
1/2
✓ Branch 0 taken 9667726 times.
✗ Branch 1 not taken.
9667726 if (script_debug_is_runtime_debugging() == 1)
35553 {
35554 runtime_script_debug_handle->print(script_debug_registers_and_stack_to_string().c_str());
35555 runtime_script_debug_handle->print("\n");
35556 }
35557
35558 int32_t result;
35559
2/2
✓ Branch 0 taken 9666731 times.
✓ Branch 1 taken 995 times.
9667726 if (jitted_script)
35560 {
35561
2/2
✓ Branch 0 taken 9586627 times.
✓ Branch 1 taken 80104 times.
9666731 if (got_initialized)
35562 80104 jit_reinit(jitted_script);
35563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9666731 times.
9666731 if (ri->waitframes)
35564 {
35565 --ri->waitframes;
35566 result = RUNSCRIPT_OK;
35567 }
35568 else
35569 {
35570 9666731 result = jit_run_script(jitted_script);
35571 }
35572 9666731 }
35573 else
35574 {
35575 995 result = run_script_int(false);
35576 }
35577
35578
6/16
✗ Branch 0 not taken.
✓ Branch 1 taken 9667726 times.
✓ Branch 2 taken 9667726 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9667726 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 9667726 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 9667726 times.
✓ Branch 10 taken 9667726 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
19335452 if (replay_is_active() && replay_get_meta_bool("debug_script_state"))
35579 {
35580 std::string str = script_debug_registers_and_stack_to_string();
35581 util::replstr(str, "\n", " ");
35582 replay_step_comment(str);
35583 }
35584
35585 #ifdef _SCRIPT_COUNTER
35586 if (replay_get_frame() > 10000-50)
35587 {
35588 al_trace("\nPrinting ZASM timings:\n\n");
35589
35590 std::vector<std::pair<int, int>> timing_results;
35591 for (int j = 0; j < NUMCOMMANDS; j++)
35592 {
35593 if (script_execount[j])
35594 {
35595 int32_t ms = script_timer[j] / 1000000.0;
35596 timing_results.push_back({j, ms});
35597 }
35598 }
35599 std::sort(timing_results.begin(), timing_results.end(), [](auto &left, auto &right) {
35600 return left.second > right.second;
35601 });
35602 for (auto &it : timing_results)
35603 {
35604 al_trace("Command %s took %d ms complete in %ld executions.\n",
35605 script_debug_command_to_string(it.first).c_str(), it.second, script_execount[it.first]);
35606 }
35607 }
35608 #endif
35609
35610
1/2
✓ Branch 0 taken 9667726 times.
✗ Branch 1 not taken.
9667726 if (runtime_script_debug_handle)
35611 runtime_script_debug_handle->print(fmt::format("result: {}\n", result).c_str());
35612 9667726 return result;
35613 10309284 }
35614
35615 714815357 int32_t run_script_int(bool is_jitted)
35616 {
35617 714815357 ScriptType type = curScriptType;
35618 714815357 word script = curScriptNum;
35619 714815357 int32_t i = curScriptIndex;
35620
35621 714815357 int commands_run = 0;
35622
2/2
✓ Branch 0 taken 714814362 times.
✓ Branch 1 taken 995 times.
714815357 if (is_jitted) goto j_command;
35623
35624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 995 times.
995 if(ri->waitframes)
35625 {
35626 --ri->waitframes;
35627 return RUNSCRIPT_OK;
35628 }
35629 995 zs_vargs.clear();
35630
35631 #ifdef _FFDISSASSEMBLY
35632
35633 if(curscript->zasm[ri->pc].command != 0xFFFF)
35634 {
35635 #ifdef _FFONESCRIPTDISSASSEMBLY
35636 zc_trace_clear();
35637 #endif
35638
35639 switch(type)
35640 {
35641 case ScriptType::FFC:
35642 al_trace("\nStart of FFC script %i processing on FFC %i:\n", script, i);
35643 break;
35644
35645 case ScriptType::Item:
35646 al_trace("\nStart of item script %i processing:\n", script);
35647 break;
35648
35649 case ScriptType::Global:
35650 al_trace("\nStart of global script %I processing:\n", script);
35651 break;
35652 }
35653 }
35654
35655 #endif
35656
35657
2/4
✓ Branch 0 taken 995 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 995 times.
1990 if( FFCore.zasm_break_mode == ZASM_BREAK_ADVANCE_SCRIPT || FFCore.zasm_break_mode == ZASM_BREAK_SKIP_SCRIPT )
35658 {
35659 if( zasm_debugger )
35660 {
35661 //Halt on new script if set to advance to next script
35662 FFCore.zasm_break_mode = ZASM_BREAK_HALT;
35663 FFCore.TraceScriptIDs(true);
35664 coloured_console.safeprint((CConsoleLoggerEx::COLOR_RED |
35665 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),"Breaking for script start\n");
35666 }
35667 else FFCore.zasm_break_mode = ZASM_BREAK_NONE;
35668 }
35669
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 995 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
995 else if( zasm_debugger && !(SKIPZASMPRINT()))
35670 {
35671 //Print new script metadata when starting script
35672 FFCore.TraceScriptIDs(true);
35673 coloured_console.safeprint((CConsoleLoggerEx::COLOR_RED |
35674 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),"Start of script\n");
35675 }
35676
35677 j_command:
35678 714815357 bool is_debugging = script_debug_is_runtime_debugging() == 2;
35679 714815357 bool increment = true;
35680 714815357 word scommand = curscript->zasm[ri->pc].command;
35681 714815357 bool hit_invalid_zasm = false;
35682 714815357 bool no_dealloc = false;
35683
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 717908326 times.
717909334 while(scommand != 0xFFFF)
35684 {
35685 #ifdef _SCRIPT_COUNTER
35686 std::chrono::steady_clock::time_point start_time, end_time;
35687 start_time = std::chrono::steady_clock::now();
35688 #endif
35689
35690 717908326 scommand = curscript->zasm[ri->pc].command;
35691 717908326 sarg1 = curscript->zasm[ri->pc].arg1;
35692 717908326 sarg2 = curscript->zasm[ri->pc].arg2;
35693 717908326 sargstr = curscript->zasm[ri->pc].strptr;
35694 717908326 sargvec = curscript->zasm[ri->pc].vecptr;
35695 //zprint2("Executing zasm: %d,%d,%d,%d,%d\n",scommand,sarg1,sarg2,get_register(sarg1),get_register(sarg2));
35696
35697
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 717908326 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
717908326 if (is_debugging && (!is_jitted || commands_run > 0))
35698 {
35699 runtime_script_debug_handle->pre_command();
35700 }
35701
35702 717908326 bool waiting = true;
35703
4/6
✓ Branch 0 taken 708311087 times.
✓ Branch 1 taken 1865574 times.
✓ Branch 2 taken 177522 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7554143 times.
✗ Branch 5 not taken.
717908326 switch(scommand) //Handle waitframe-type commands first
35704 {
35705 case WAITDRAW:
35706 {
35707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1865574 times.
1865574 if(script_funcrun)
35708 scommand = NOP;
35709
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1865574 times.
✗ Branch 2 not taken.
1865574 else switch(type)
35710 {
35711 case ScriptType::EngineSubscreen: //ignore waitdraws
35712 Z_scripterrlog("'Waitdraw()' is invalid in subscreen scripts, will be ignored\n");
35713 scommand = NOP;
35714 break;
35715 case ScriptType::Generic:
35716 case ScriptType::GenericFrozen: //ignore waitdraws
35717 Z_scripterrlog("'Waitdraw()' is invalid in generic scripts, will be ignored\n");
35718 scommand = NOP;
35719 break;
35720 }
35721 1865574 break;
35722 }
35723 case WAITTO:
35724 {
35725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177522 times.
177522 if(script_funcrun)
35726 scommand = NOP;
35727
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 177522 times.
177522 else switch(type)
35728 {
35729 case ScriptType::GenericFrozen:
35730 //ignore, no warn/error
35731 scommand = NOP;
35732 break;
35733 case ScriptType::Generic:
35734 {
35735 177522 user_genscript& scr = user_scripts[script];
35736 177522 int32_t target = get_register(sarg1)/10000L;
35737 177522 bool atleast = get_register(sarg2)!=0;
35738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177522 times.
177522 if(unsigned(target) > SCR_TIMING_END_FRAME)
35739 {
35740 Z_scripterrlog("Invalid value '%d' provided to 'WaitTo()'\n", target);
35741 scommand = NOP;
35742 break;
35743 }
35744
1/4
✓ Branch 0 taken 177522 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
177522 if(genscript_timing == target ||
35745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177522 times.
177522 (atleast && genscript_timing < target))
35746 {
35747 //Already that time, skip the command
35748 scommand = NOP;
35749 break;
35750 }
35751 177522 scr.waituntil = scr_timing(target);
35752 177522 scr.wait_atleast = atleast;
35753 177522 break;
35754 }
35755 default:
35756 Z_scripterrlog("'WaitTo()' is only valid in 'generic' scripts!\n");
35757 scommand = NOP;
35758 break;
35759 }
35760 177522 break;
35761 }
35762 case WAITEVENT:
35763 {
35764 if(script_funcrun)
35765 scommand = NOP;
35766 else switch(type)
35767 {
35768 case ScriptType::GenericFrozen:
35769 scommand = WAITFRAME;
35770 ri->d[0] = GENSCR_EVENT_NIL*10000; //no event
35771 break;
35772 case ScriptType::Generic:
35773 {
35774 user_genscript& scr = user_scripts[script];
35775 scr.waitevent = true;
35776 break;
35777 }
35778 default:
35779 Z_scripterrlog("'WaitEvent()' is only valid in 'generic' scripts!\n");
35780 scommand = NOP;
35781 break;
35782 }
35783 break;
35784 }
35785 case WAITFRAME:
35786 {
35787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7554143 times.
7554143 if(script_funcrun)
35788 scommand = NOP;
35789
2/2
✓ Branch 0 taken 7287580 times.
✓ Branch 1 taken 266563 times.
7554143 else switch(type)
35790 {
35791 case ScriptType::Generic:
35792 266563 user_scripts[script].waituntil = SCR_TIMING_START_FRAME;
35793 266563 user_scripts[script].wait_atleast = false;
35794 266563 break;
35795 }
35796 7554143 break;
35797 }
35798 case WAITFRAMESR:
35799 {
35800 auto count = get_register(sarg1);
35801 if(script_funcrun || count <= 0)
35802 {
35803 scommand = NOP;
35804 break;
35805 }
35806 auto frames = count/10000;
35807 if(count%10000) ++frames; //round up decimals
35808 ri->waitframes = frames-1; //this frame doesn't count
35809 switch(type)
35810 {
35811 case ScriptType::Generic:
35812 user_scripts[script].waituntil = SCR_TIMING_START_FRAME;
35813 user_scripts[script].wait_atleast = false;
35814 break;
35815 }
35816 break;
35817 }
35818 708311087 default: waiting = false;
35819 708311087 }
35820
3/4
✓ Branch 0 taken 9597239 times.
✓ Branch 1 taken 708311087 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9597239 times.
717908326 if(waiting && scommand != NOP)
35821 9597239 break;
35822
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 708311087 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
708311087 if(waiting && is_jitted)
35823 break;
35824
35825 708311087 numInstructions++;
35826
2/2
✓ Branch 0 taken 707602804 times.
✓ Branch 1 taken 708283 times.
708311087 if(numInstructions==hangcount) // No need to check frequently
35827 {
35828 708283 numInstructions=0;
35829 708283 poll_keyboard();
35830 708283 checkQuitKeys();
35831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708283 times.
708283 if(Quit)
35832 scommand=0xFFFF;
35833 708283 }
35834
35835 //Handle manual breaking
35836
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 708311087 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
708311087 if( zasm_debugger && zc_readrawkey(KEY_INSERT, true))
35837 FFCore.zasm_break_mode = ZASM_BREAK_HALT;
35838 //Break
35839
1/2
✓ Branch 0 taken 708311087 times.
✗ Branch 1 not taken.
708311087 while( FFCore.zasm_break_mode == ZASM_BREAK_HALT )
35840 {
35841 poll_keyboard();
35842 if(zasm_advance()) break;
35843 checkQuitKeys();
35844 if(Quit)
35845 {
35846 scommand=0xFFFF;
35847 break;
35848 }
35849 }
35850
35851
1/2
✓ Branch 0 taken 708311087 times.
✗ Branch 1 not taken.
708311087 if ( zasm_debugger ) FFCore.ZASMPrintCommand(scommand);
35852
145/931
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 864999 times.
✓ Branch 6 taken 1259 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4761 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 22 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✓ Branch 58 taken 589788 times.
✓ Branch 59 taken 37364177 times.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✓ Branch 65 taken 69469 times.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✗ Branch 81 not taken.
✗ Branch 82 not taken.
✗ Branch 83 not taken.
✓ Branch 84 taken 62716619 times.
✓ Branch 85 taken 31889313 times.
✓ Branch 86 taken 38156302 times.
✗ Branch 87 not taken.
✓ Branch 88 taken 22093501 times.
✓ Branch 89 taken 2928911 times.
✓ Branch 90 taken 241209 times.
✓ Branch 91 taken 333 times.
✗ Branch 92 not taken.
✗ Branch 93 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✗ Branch 96 not taken.
✗ Branch 97 not taken.
✗ Branch 98 not taken.
✗ Branch 99 not taken.
✗ Branch 100 not taken.
✗ Branch 101 not taken.
✗ Branch 102 not taken.
✗ Branch 103 not taken.
✗ Branch 104 not taken.
✗ Branch 105 not taken.
✗ Branch 106 not taken.
✗ Branch 107 not taken.
✗ Branch 108 not taken.
✓ Branch 109 taken 70999 times.
✗ Branch 110 not taken.
✗ Branch 111 not taken.
✗ Branch 112 not taken.
✗ Branch 113 not taken.
✗ Branch 114 not taken.
✗ Branch 115 not taken.
✗ Branch 116 not taken.
✗ Branch 117 not taken.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✗ Branch 120 not taken.
✗ Branch 121 not taken.
✓ Branch 122 taken 332 times.
✗ Branch 123 not taken.
✓ Branch 124 taken 7024960 times.
✗ Branch 125 not taken.
✗ Branch 126 not taken.
✗ Branch 127 not taken.
✓ Branch 128 taken 7000433 times.
✗ Branch 129 not taken.
✗ Branch 130 not taken.
✓ Branch 131 taken 294114413 times.
✗ Branch 132 not taken.
✗ Branch 133 not taken.
✗ Branch 134 not taken.
✗ Branch 135 not taken.
✗ Branch 136 not taken.
✓ Branch 137 taken 227724 times.
✓ Branch 138 taken 80 times.
✗ Branch 139 not taken.
✗ Branch 140 not taken.
✗ Branch 141 not taken.
✗ Branch 142 not taken.
✗ Branch 143 not taken.
✗ Branch 144 not taken.
✗ Branch 145 not taken.
✗ Branch 146 not taken.
✗ Branch 147 not taken.
✓ Branch 148 taken 930 times.
✗ Branch 149 not taken.
✗ Branch 150 not taken.
✗ Branch 151 not taken.
✓ Branch 152 taken 6164970 times.
✗ Branch 153 not taken.
✓ Branch 154 taken 3205819 times.
✗ Branch 155 not taken.
✓ Branch 156 taken 76 times.
✓ Branch 157 taken 1263 times.
✓ Branch 158 taken 60936 times.
✓ Branch 159 taken 2629 times.
✓ Branch 160 taken 14918 times.
✗ Branch 161 not taken.
✓ Branch 162 taken 13724 times.
✓ Branch 163 taken 37547 times.
✗ Branch 164 not taken.
✗ Branch 165 not taken.
✓ Branch 166 taken 1 times.
✓ Branch 167 taken 1072 times.
✗ Branch 168 not taken.
✗ Branch 169 not taken.
✗ Branch 170 not taken.
✗ Branch 171 not taken.
✗ Branch 172 not taken.
✗ Branch 173 not taken.
✗ Branch 174 not taken.
✗ Branch 175 not taken.
✗ Branch 176 not taken.
✗ Branch 177 not taken.
✗ Branch 178 not taken.
✗ Branch 179 not taken.
✗ Branch 180 not taken.
✗ Branch 181 not taken.
✗ Branch 182 not taken.
✗ Branch 183 not taken.
✗ Branch 184 not taken.
✓ Branch 185 taken 1 times.
✗ Branch 186 not taken.
✗ Branch 187 not taken.
✗ Branch 188 not taken.
✓ Branch 189 taken 602 times.
✓ Branch 190 taken 1275 times.
✗ Branch 191 not taken.
✓ Branch 192 taken 68 times.
✓ Branch 193 taken 105 times.
✗ Branch 194 not taken.
✓ Branch 195 taken 31 times.
✗ Branch 196 not taken.
✗ Branch 197 not taken.
✗ Branch 198 not taken.
✗ Branch 199 not taken.
✗ Branch 200 not taken.
✗ Branch 201 not taken.
✗ Branch 202 not taken.
✗ Branch 203 not taken.
✓ Branch 204 taken 27143 times.
✓ Branch 205 taken 72 times.
✗ Branch 206 not taken.
✗ Branch 207 not taken.
✓ Branch 208 taken 27147 times.
✓ Branch 209 taken 32662 times.
✓ Branch 210 taken 2703958 times.
✗ Branch 211 not taken.
✗ Branch 212 not taken.
✗ Branch 213 not taken.
✗ Branch 214 not taken.
✗ Branch 215 not taken.
✗ Branch 216 not taken.
✗ Branch 217 not taken.
✗ Branch 218 not taken.
✓ Branch 219 taken 2539388 times.
✓ Branch 220 taken 77 times.
✗ Branch 221 not taken.
✗ Branch 222 not taken.
✗ Branch 223 not taken.
✗ Branch 224 not taken.
✗ Branch 225 not taken.
✗ Branch 226 not taken.
✗ Branch 227 not taken.
✓ Branch 228 taken 27 times.
✓ Branch 229 taken 20 times.
✗ Branch 230 not taken.
✗ Branch 231 not taken.
✓ Branch 232 taken 5580678 times.
✓ Branch 233 taken 155486 times.
✓ Branch 234 taken 191294 times.
✓ Branch 235 taken 3 times.
✗ Branch 236 not taken.
✗ Branch 237 not taken.
✗ Branch 238 not taken.
✗ Branch 239 not taken.
✗ Branch 240 not taken.
✗ Branch 241 not taken.
✓ Branch 242 taken 1427960 times.
✓ Branch 243 taken 62332728 times.
✓ Branch 244 taken 511915 times.
✓ Branch 245 taken 20228359 times.
✓ Branch 246 taken 377549 times.
✓ Branch 247 taken 34306 times.
✗ Branch 248 not taken.
✓ Branch 249 taken 17 times.
✗ Branch 250 not taken.
✗ Branch 251 not taken.
✗ Branch 252 not taken.
✗ Branch 253 not taken.
✓ Branch 254 taken 22 times.
✗ Branch 255 not taken.
✓ Branch 256 taken 34296 times.
✗ Branch 257 not taken.
✓ Branch 258 taken 3603 times.
✗ Branch 259 not taken.
✗ Branch 260 not taken.
✗ Branch 261 not taken.
✗ Branch 262 not taken.
✗ Branch 263 not taken.
✗ Branch 264 not taken.
✗ Branch 265 not taken.
✗ Branch 266 not taken.
✗ Branch 267 not taken.
✗ Branch 268 not taken.
✗ Branch 269 not taken.
✗ Branch 270 not taken.
✗ Branch 271 not taken.
✓ Branch 272 taken 2 times.
✓ Branch 273 taken 1 times.
✓ Branch 274 taken 384 times.
✓ Branch 275 taken 287 times.
✓ Branch 276 taken 11645 times.
✓ Branch 277 taken 3322 times.
✗ Branch 278 not taken.
✗ Branch 279 not taken.
✗ Branch 280 not taken.
✗ Branch 281 not taken.
✗ Branch 282 not taken.
✗ Branch 283 not taken.
✗ Branch 284 not taken.
✓ Branch 285 taken 79 times.
✗ Branch 286 not taken.
✓ Branch 287 taken 126 times.
✗ Branch 288 not taken.
✗ Branch 289 not taken.
✓ Branch 290 taken 5580 times.
✗ Branch 291 not taken.
✓ Branch 292 taken 5268 times.
✗ Branch 293 not taken.
✗ Branch 294 not taken.
✓ Branch 295 taken 170878 times.
✗ Branch 296 not taken.
✗ Branch 297 not taken.
✗ Branch 298 not taken.
✗ Branch 299 not taken.
✗ Branch 300 not taken.
✗ Branch 301 not taken.
✗ Branch 302 not taken.
✓ Branch 303 taken 63813 times.
✗ Branch 304 not taken.
✓ Branch 305 taken 79 times.
✓ Branch 306 taken 100 times.
✓ Branch 307 taken 5 times.
✓ Branch 308 taken 3750 times.
✗ Branch 309 not taken.
✗ Branch 310 not taken.
✗ Branch 311 not taken.
✗ Branch 312 not taken.
✗ Branch 313 not taken.
✗ Branch 314 not taken.
✗ Branch 315 not taken.
✗ Branch 316 not taken.
✗ Branch 317 not taken.
✗ Branch 318 not taken.
✗ Branch 319 not taken.
✗ Branch 320 not taken.
✗ Branch 321 not taken.
✗ Branch 322 not taken.
✓ Branch 323 taken 173 times.
✗ Branch 324 not taken.
✓ Branch 325 taken 2691 times.
✗ Branch 326 not taken.
✗ Branch 327 not taken.
✓ Branch 328 taken 10 times.
✗ Branch 329 not taken.
✓ Branch 330 taken 3666 times.
✗ Branch 331 not taken.
✗ Branch 332 not taken.
✓ Branch 333 taken 701 times.
✗ Branch 334 not taken.
✗ Branch 335 not taken.
✗ Branch 336 not taken.
✓ Branch 337 taken 1201098 times.
✗ Branch 338 not taken.
✓ Branch 339 taken 2753647 times.
✗ Branch 340 not taken.
✓ Branch 341 taken 136832 times.
✗ Branch 342 not taken.
✓ Branch 343 taken 1816935 times.
✗ Branch 344 not taken.
✗ Branch 345 not taken.
✗ Branch 346 not taken.
✗ Branch 347 not taken.
✗ Branch 348 not taken.
✗ Branch 349 not taken.
✓ Branch 350 taken 25412 times.
✗ Branch 351 not taken.
✗ Branch 352 not taken.
✓ Branch 353 taken 403560 times.
✓ Branch 354 taken 177544 times.
✓ Branch 355 taken 16 times.
✗ Branch 356 not taken.
✗ Branch 357 not taken.
✗ Branch 358 not taken.
✗ Branch 359 not taken.
✗ Branch 360 not taken.
✓ Branch 361 taken 802539 times.
✗ Branch 362 not taken.
✗ Branch 363 not taken.
✗ Branch 364 not taken.
✗ Branch 365 not taken.
✗ Branch 366 not taken.
✗ Branch 367 not taken.
✗ Branch 368 not taken.
✗ Branch 369 not taken.
✗ Branch 370 not taken.
✗ Branch 371 not taken.
✗ Branch 372 not taken.
✗ Branch 373 not taken.
✗ Branch 374 not taken.
✗ Branch 375 not taken.
✗ Branch 376 not taken.
✗ Branch 377 not taken.
✗ Branch 378 not taken.
✗ Branch 379 not taken.
✗ Branch 380 not taken.
✗ Branch 381 not taken.
✗ Branch 382 not taken.
✗ Branch 383 not taken.
✗ Branch 384 not taken.
✗ Branch 385 not taken.
✗ Branch 386 not taken.
✗ Branch 387 not taken.
✗ Branch 388 not taken.
✗ Branch 389 not taken.
✗ Branch 390 not taken.
✗ Branch 391 not taken.
✗ Branch 392 not taken.
✗ Branch 393 not taken.
✗ Branch 394 not taken.
✗ Branch 395 not taken.
✗ Branch 396 not taken.
✗ Branch 397 not taken.
✗ Branch 398 not taken.
✗ Branch 399 not taken.
✗ Branch 400 not taken.
✗ Branch 401 not taken.
✗ Branch 402 not taken.
✗ Branch 403 not taken.
✗ Branch 404 not taken.
✗ Branch 405 not taken.
✗ Branch 406 not taken.
✗ Branch 407 not taken.
✗ Branch 408 not taken.
✗ Branch 409 not taken.
✗ Branch 410 not taken.
✗ Branch 411 not taken.
✓ Branch 412 taken 12 times.
✓ Branch 413 taken 598 times.
✗ Branch 414 not taken.
✓ Branch 415 taken 15644354 times.
✗ Branch 416 not taken.
✓ Branch 417 taken 77278 times.
✗ Branch 418 not taken.
✓ Branch 419 taken 131917 times.
✗ Branch 420 not taken.
✓ Branch 421 taken 21343 times.
✗ Branch 422 not taken.
✓ Branch 423 taken 2363 times.
✗ Branch 424 not taken.
✓ Branch 425 taken 565 times.
✓ Branch 426 taken 27033 times.
✓ Branch 427 taken 5 times.
✓ Branch 428 taken 43 times.
✓ Branch 429 taken 6266198 times.
✓ Branch 430 taken 593592 times.
✓ Branch 431 taken 122622 times.
✗ Branch 432 not taken.
✗ Branch 433 not taken.
✗ Branch 434 not taken.
✗ Branch 435 not taken.
✓ Branch 436 taken 15079 times.
✗ Branch 437 not taken.
✓ Branch 438 taken 132144 times.
✗ Branch 439 not taken.
✗ Branch 440 not taken.
✗ Branch 441 not taken.
✓ Branch 442 taken 16274958 times.
✗ Branch 443 not taken.
✗ Branch 444 not taken.
✗ Branch 445 not taken.
✓ Branch 446 taken 249 times.
✓ Branch 447 taken 5 times.
✓ Branch 448 taken 354940 times.
✗ Branch 449 not taken.
✗ Branch 450 not taken.
✓ Branch 451 taken 354943 times.
✓ Branch 452 taken 3 times.
✓ Branch 453 taken 3 times.
✓ Branch 454 taken 12696160 times.
✓ Branch 455 taken 16038753 times.
✓ Branch 456 taken 60 times.
✗ Branch 457 not taken.
✗ Branch 458 not taken.
✗ Branch 459 not taken.
✗ Branch 460 not taken.
✗ Branch 461 not taken.
✗ Branch 462 not taken.
✗ Branch 463 not taken.
✗ Branch 464 not taken.
✗ Branch 465 not taken.
✗ Branch 466 not taken.
✗ Branch 467 not taken.
✗ Branch 468 not taken.
✗ Branch 469 not taken.
✗ Branch 470 not taken.
✗ Branch 471 not taken.
✗ Branch 472 not taken.
✗ Branch 473 not taken.
✓ Branch 474 taken 2564 times.
✗ Branch 475 not taken.
✗ Branch 476 not taken.
✗ Branch 477 not taken.
✗ Branch 478 not taken.
✓ Branch 479 taken 26528 times.
✓ Branch 480 taken 3512 times.
✓ Branch 481 taken 146 times.
✗ Branch 482 not taken.
✗ Branch 483 not taken.
✗ Branch 484 not taken.
✗ Branch 485 not taken.
✗ Branch 486 not taken.
✗ Branch 487 not taken.
✗ Branch 488 not taken.
✗ Branch 489 not taken.
✗ Branch 490 not taken.
✗ Branch 491 not taken.
✓ Branch 492 taken 16962076 times.
✗ Branch 493 not taken.
✗ Branch 494 not taken.
✗ Branch 495 not taken.
✗ Branch 496 not taken.
✗ Branch 497 not taken.
✓ Branch 498 taken 57032 times.
✗ Branch 499 not taken.
✗ Branch 500 not taken.
✗ Branch 501 not taken.
✗ Branch 502 not taken.
✗ Branch 503 not taken.
✗ Branch 504 not taken.
✗ Branch 505 not taken.
✗ Branch 506 not taken.
✗ Branch 507 not taken.
✗ Branch 508 not taken.
✗ Branch 509 not taken.
✗ Branch 510 not taken.
✓ Branch 511 taken 3535588 times.
✓ Branch 512 taken 1 times.
✗ Branch 513 not taken.
✗ Branch 514 not taken.
✗ Branch 515 not taken.
✗ Branch 516 not taken.
✗ Branch 517 not taken.
✗ Branch 518 not taken.
✓ Branch 519 taken 11 times.
✗ Branch 520 not taken.
✗ Branch 521 not taken.
✗ Branch 522 not taken.
✗ Branch 523 not taken.
✗ Branch 524 not taken.
✗ Branch 525 not taken.
✗ Branch 526 not taken.
✗ Branch 527 not taken.
✗ Branch 528 not taken.
✗ Branch 529 not taken.
✗ Branch 530 not taken.
✗ Branch 531 not taken.
✗ Branch 532 not taken.
✗ Branch 533 not taken.
✗ Branch 534 not taken.
✗ Branch 535 not taken.
✗ Branch 536 not taken.
✗ Branch 537 not taken.
✗ Branch 538 not taken.
✗ Branch 539 not taken.
✗ Branch 540 not taken.
✗ Branch 541 not taken.
✗ Branch 542 not taken.
✗ Branch 543 not taken.
✗ Branch 544 not taken.
✗ Branch 545 not taken.
✓ Branch 546 taken 16 times.
✗ Branch 547 not taken.
✗ Branch 548 not taken.
✗ Branch 549 not taken.
✗ Branch 550 not taken.
✗ Branch 551 not taken.
✗ Branch 552 not taken.
✗ Branch 553 not taken.
✗ Branch 554 not taken.
✗ Branch 555 not taken.
✗ Branch 556 not taken.
✗ Branch 557 not taken.
✗ Branch 558 not taken.
✗ Branch 559 not taken.
✗ Branch 560 not taken.
✗ Branch 561 not taken.
✗ Branch 562 not taken.
✗ Branch 563 not taken.
✗ Branch 564 not taken.
✗ Branch 565 not taken.
✗ Branch 566 not taken.
✗ Branch 567 not taken.
✗ Branch 568 not taken.
✗ Branch 569 not taken.
✗ Branch 570 not taken.
✗ Branch 571 not taken.
✗ Branch 572 not taken.
✓ Branch 573 taken 15 times.
✗ Branch 574 not taken.
✗ Branch 575 not taken.
✗ Branch 576 not taken.
✗ Branch 577 not taken.
✗ Branch 578 not taken.
✗ Branch 579 not taken.
✗ Branch 580 not taken.
✗ Branch 581 not taken.
✗ Branch 582 not taken.
✗ Branch 583 not taken.
✗ Branch 584 not taken.
✗ Branch 585 not taken.
✗ Branch 586 not taken.
✗ Branch 587 not taken.
✗ Branch 588 not taken.
✗ Branch 589 not taken.
✗ Branch 590 not taken.
✗ Branch 591 not taken.
✗ Branch 592 not taken.
✗ Branch 593 not taken.
✗ Branch 594 not taken.
✗ Branch 595 not taken.
✗ Branch 596 not taken.
✗ Branch 597 not taken.
✗ Branch 598 not taken.
✗ Branch 599 not taken.
✗ Branch 600 not taken.
✗ Branch 601 not taken.
✗ Branch 602 not taken.
✗ Branch 603 not taken.
✗ Branch 604 not taken.
✗ Branch 605 not taken.
✗ Branch 606 not taken.
✗ Branch 607 not taken.
✗ Branch 608 not taken.
✗ Branch 609 not taken.
✗ Branch 610 not taken.
✗ Branch 611 not taken.
✗ Branch 612 not taken.
✗ Branch 613 not taken.
✗ Branch 614 not taken.
✗ Branch 615 not taken.
✗ Branch 616 not taken.
✗ Branch 617 not taken.
✗ Branch 618 not taken.
✗ Branch 619 not taken.
✗ Branch 620 not taken.
✗ Branch 621 not taken.
✗ Branch 622 not taken.
✗ Branch 623 not taken.
✗ Branch 624 not taken.
✗ Branch 625 not taken.
✗ Branch 626 not taken.
✗ Branch 627 not taken.
✗ Branch 628 not taken.
✗ Branch 629 not taken.
✗ Branch 630 not taken.
✗ Branch 631 not taken.
✗ Branch 632 not taken.
✗ Branch 633 not taken.
✗ Branch 634 not taken.
✗ Branch 635 not taken.
✗ Branch 636 not taken.
✗ Branch 637 not taken.
✗ Branch 638 not taken.
✗ Branch 639 not taken.
✗ Branch 640 not taken.
✗ Branch 641 not taken.
✗ Branch 642 not taken.
✗ Branch 643 not taken.
✗ Branch 644 not taken.
✗ Branch 645 not taken.
✗ Branch 646 not taken.
✗ Branch 647 not taken.
✗ Branch 648 not taken.
✗ Branch 649 not taken.
✗ Branch 650 not taken.
✗ Branch 651 not taken.
✗ Branch 652 not taken.
✗ Branch 653 not taken.
✗ Branch 654 not taken.
✗ Branch 655 not taken.
✗ Branch 656 not taken.
✗ Branch 657 not taken.
✗ Branch 658 not taken.
✗ Branch 659 not taken.
✗ Branch 660 not taken.
✗ Branch 661 not taken.
✗ Branch 662 not taken.
✗ Branch 663 not taken.
✗ Branch 664 not taken.
✗ Branch 665 not taken.
✗ Branch 666 not taken.
✗ Branch 667 not taken.
✗ Branch 668 not taken.
✗ Branch 669 not taken.
✗ Branch 670 not taken.
✗ Branch 671 not taken.
✗ Branch 672 not taken.
✗ Branch 673 not taken.
✗ Branch 674 not taken.
✗ Branch 675 not taken.
✗ Branch 676 not taken.
✗ Branch 677 not taken.
✗ Branch 678 not taken.
✗ Branch 679 not taken.
✗ Branch 680 not taken.
✗ Branch 681 not taken.
✗ Branch 682 not taken.
✗ Branch 683 not taken.
✗ Branch 684 not taken.
✗ Branch 685 not taken.
✗ Branch 686 not taken.
✗ Branch 687 not taken.
✗ Branch 688 not taken.
✗ Branch 689 not taken.
✗ Branch 690 not taken.
✗ Branch 691 not taken.
✗ Branch 692 not taken.
✗ Branch 693 not taken.
✗ Branch 694 not taken.
✗ Branch 695 not taken.
✗ Branch 696 not taken.
✗ Branch 697 not taken.
✗ Branch 698 not taken.
✗ Branch 699 not taken.
✗ Branch 700 not taken.
✗ Branch 701 not taken.
✗ Branch 702 not taken.
✗ Branch 703 not taken.
✗ Branch 704 not taken.
✗ Branch 705 not taken.
✗ Branch 706 not taken.
✗ Branch 707 not taken.
✗ Branch 708 not taken.
✗ Branch 709 not taken.
✗ Branch 710 not taken.
✗ Branch 711 not taken.
✗ Branch 712 not taken.
✗ Branch 713 not taken.
✗ Branch 714 not taken.
✗ Branch 715 not taken.
✗ Branch 716 not taken.
✗ Branch 717 not taken.
✗ Branch 718 not taken.
✗ Branch 719 not taken.
✗ Branch 720 not taken.
✗ Branch 721 not taken.
✗ Branch 722 not taken.
✗ Branch 723 not taken.
✗ Branch 724 not taken.
✗ Branch 725 not taken.
✗ Branch 726 not taken.
✗ Branch 727 not taken.
✗ Branch 728 not taken.
✗ Branch 729 not taken.
✗ Branch 730 not taken.
✗ Branch 731 not taken.
✗ Branch 732 not taken.
✗ Branch 733 not taken.
✗ Branch 734 not taken.
✗ Branch 735 not taken.
✗ Branch 736 not taken.
✗ Branch 737 not taken.
✗ Branch 738 not taken.
✗ Branch 739 not taken.
✗ Branch 740 not taken.
✗ Branch 741 not taken.
✗ Branch 742 not taken.
✗ Branch 743 not taken.
✗ Branch 744 not taken.
✗ Branch 745 not taken.
✗ Branch 746 not taken.
✗ Branch 747 not taken.
✗ Branch 748 not taken.
✗ Branch 749 not taken.
✗ Branch 750 not taken.
✗ Branch 751 not taken.
✗ Branch 752 not taken.
✗ Branch 753 not taken.
✗ Branch 754 not taken.
✗ Branch 755 not taken.
✗ Branch 756 not taken.
✗ Branch 757 not taken.
✗ Branch 758 not taken.
✗ Branch 759 not taken.
✗ Branch 760 not taken.
✗ Branch 761 not taken.
✗ Branch 762 not taken.
✗ Branch 763 not taken.
✗ Branch 764 not taken.
✗ Branch 765 not taken.
✗ Branch 766 not taken.
✗ Branch 767 not taken.
✗ Branch 768 not taken.
✗ Branch 769 not taken.
✗ Branch 770 not taken.
✗ Branch 771 not taken.
✗ Branch 772 not taken.
✗ Branch 773 not taken.
✗ Branch 774 not taken.
✗ Branch 775 not taken.
✗ Branch 776 not taken.
✗ Branch 777 not taken.
✗ Branch 778 not taken.
✗ Branch 779 not taken.
✗ Branch 780 not taken.
✗ Branch 781 not taken.
✗ Branch 782 not taken.
✗ Branch 783 not taken.
✗ Branch 784 not taken.
✗ Branch 785 not taken.
✗ Branch 786 not taken.
✗ Branch 787 not taken.
✗ Branch 788 not taken.
✗ Branch 789 not taken.
✗ Branch 790 not taken.
✗ Branch 791 not taken.
✗ Branch 792 not taken.
✗ Branch 793 not taken.
✗ Branch 794 not taken.
✗ Branch 795 not taken.
✗ Branch 796 not taken.
✗ Branch 797 not taken.
✗ Branch 798 not taken.
✗ Branch 799 not taken.
✗ Branch 800 not taken.
✗ Branch 801 not taken.
✗ Branch 802 not taken.
✗ Branch 803 not taken.
✗ Branch 804 not taken.
✗ Branch 805 not taken.
✗ Branch 806 not taken.
✗ Branch 807 not taken.
✗ Branch 808 not taken.
✗ Branch 809 not taken.
✗ Branch 810 not taken.
✗ Branch 811 not taken.
✗ Branch 812 not taken.
✗ Branch 813 not taken.
✗ Branch 814 not taken.
✗ Branch 815 not taken.
✗ Branch 816 not taken.
✗ Branch 817 not taken.
✗ Branch 818 not taken.
✗ Branch 819 not taken.
✓ Branch 820 taken 2 times.
✗ Branch 821 not taken.
✓ Branch 822 taken 8 times.
✗ Branch 823 not taken.
✗ Branch 824 not taken.
✗ Branch 825 not taken.
✗ Branch 826 not taken.
✗ Branch 827 not taken.
✗ Branch 828 not taken.
✗ Branch 829 not taken.
✗ Branch 830 not taken.
✗ Branch 831 not taken.
✗ Branch 832 not taken.
✗ Branch 833 not taken.
✗ Branch 834 not taken.
✗ Branch 835 not taken.
✗ Branch 836 not taken.
✗ Branch 837 not taken.
✗ Branch 838 not taken.
✗ Branch 839 not taken.
✗ Branch 840 not taken.
✗ Branch 841 not taken.
✗ Branch 842 not taken.
✗ Branch 843 not taken.
✗ Branch 844 not taken.
✗ Branch 845 not taken.
✗ Branch 846 not taken.
✗ Branch 847 not taken.
✗ Branch 848 not taken.
✗ Branch 849 not taken.
✗ Branch 850 not taken.
✗ Branch 851 not taken.
✗ Branch 852 not taken.
✗ Branch 853 not taken.
✗ Branch 854 not taken.
✗ Branch 855 not taken.
✗ Branch 856 not taken.
✗ Branch 857 not taken.
✗ Branch 858 not taken.
✗ Branch 859 not taken.
✗ Branch 860 not taken.
✗ Branch 861 not taken.
✗ Branch 862 not taken.
✗ Branch 863 not taken.
✗ Branch 864 not taken.
✗ Branch 865 not taken.
✓ Branch 866 taken 1 times.
✓ Branch 867 taken 1 times.
✗ Branch 868 not taken.
✗ Branch 869 not taken.
✗ Branch 870 not taken.
✓ Branch 871 taken 1 times.
✗ Branch 872 not taken.
✗ Branch 873 not taken.
✗ Branch 874 not taken.
✗ Branch 875 not taken.
✓ Branch 876 taken 1 times.
✓ Branch 877 taken 1 times.
✗ Branch 878 not taken.
✗ Branch 879 not taken.
✓ Branch 880 taken 279 times.
✗ Branch 881 not taken.
✗ Branch 882 not taken.
✗ Branch 883 not taken.
✗ Branch 884 not taken.
✗ Branch 885 not taken.
✗ Branch 886 not taken.
✗ Branch 887 not taken.
✗ Branch 888 not taken.
✗ Branch 889 not taken.
✗ Branch 890 not taken.
✗ Branch 891 not taken.
✗ Branch 892 not taken.
✗ Branch 893 not taken.
✗ Branch 894 not taken.
✗ Branch 895 not taken.
✗ Branch 896 not taken.
✗ Branch 897 not taken.
✗ Branch 898 not taken.
✗ Branch 899 not taken.
✗ Branch 900 not taken.
✗ Branch 901 not taken.
✗ Branch 902 not taken.
✗ Branch 903 not taken.
✗ Branch 904 not taken.
✓ Branch 905 taken 1338 times.
✓ Branch 906 taken 301905 times.
✗ Branch 907 not taken.
✗ Branch 908 not taken.
✗ Branch 909 not taken.
✓ Branch 910 taken 73 times.
✗ Branch 911 not taken.
✓ Branch 912 taken 6 times.
✓ Branch 913 taken 8 times.
✓ Branch 914 taken 68 times.
✓ Branch 915 taken 10 times.
✗ Branch 916 not taken.
✗ Branch 917 not taken.
✗ Branch 918 not taken.
✗ Branch 919 not taken.
✗ Branch 920 not taken.
✗ Branch 921 not taken.
✗ Branch 922 not taken.
✗ Branch 923 not taken.
✗ Branch 924 not taken.
✗ Branch 925 not taken.
✗ Branch 926 not taken.
✗ Branch 927 not taken.
✗ Branch 928 not taken.
✗ Branch 929 not taken.
✗ Branch 930 not taken.
708311087 switch(scommand)
35853 {
35854 //always first
35855 case 0xFFFF: //invalid command
35856 {
35857 const char* type_str = ScriptTypeToString(type);
35858 switch(type)
35859 {
35860 case ScriptType::FFC:
35861 zprint("%s Script %s has exited.\n", type_str, ffcmap[i].scriptname.c_str()); break;
35862 case ScriptType::NPC:
35863 zprint("%s Script %s has exited.\n", type_str, npcmap[i].scriptname.c_str()); break;
35864 case ScriptType::Lwpn:
35865 zprint("%s Script %s has exited.\n", type_str, lwpnmap[i].scriptname.c_str()); break;
35866 case ScriptType::Ewpn:
35867 zprint("%s Script %s has exited.\n", type_str, ewpnmap[i].scriptname.c_str()); break;
35868 case ScriptType::ItemSprite:
35869 zprint("%s Script %s has exited.\n", type_str, itemspritemap[i].scriptname.c_str()); break;
35870 case ScriptType::Item:
35871 zprint("%s Script %s has exited.\n", type_str, itemmap[i].scriptname.c_str()); break;
35872 case ScriptType::Global:
35873 zprint("%s Script %s has exited.\n", type_str, globalmap[i].scriptname.c_str()); break;
35874 case ScriptType::Player:
35875 zprint("%s Script %s has exited.\n", type_str, playermap[i].scriptname.c_str()); break;
35876 case ScriptType::Screen:
35877 zprint("%s Script %s has exited.\n", type_str, screenmap[i].scriptname.c_str()); break;
35878 case ScriptType::OnMap:
35879 case ScriptType::DMap:
35880 case ScriptType::ScriptedActiveSubscreen:
35881 case ScriptType::ScriptedPassiveSubscreen:
35882 zprint("%s Script %s has exited.\n", type_str, dmapmap[i].scriptname.c_str()); break;
35883 case ScriptType::Combo: zprint("%s Script %s has exited.\n", type_str, comboscriptmap[i].scriptname.c_str()); break;
35884
35885 default: break;
35886 }
35887 break;
35888 }
35889 case QUIT:
35890 69469 scommand = 0xFFFF;
35891 69469 break;
35892 case QUIT_NO_DEALLOC:
35893 scommand = 0xFFFF;
35894 no_dealloc = true;
35895 break;
35896
35897 case NOP: //No Operation. Do nothing. -Em
35898 break;
35899 case GOTO:
35900 {
35901 uint8_t invalid = 0;
35902 if(sarg1 < 0 )
35903 {
35904 const char* type_str = ScriptTypeToString(type);
35905 switch(type)
35906 {
35907 case ScriptType::FFC:
35908 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str(), sarg1); break;
35909 case ScriptType::NPC:
35910 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
35911 case ScriptType::Lwpn:
35912 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
35913 case ScriptType::Ewpn:
35914 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
35915 case ScriptType::ItemSprite:
35916 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
35917 case ScriptType::Item:
35918 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
35919 case ScriptType::Global:
35920 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
35921 case ScriptType::Player:
35922 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
35923 case ScriptType::Screen:
35924 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
35925 case ScriptType::OnMap:
35926 case ScriptType::DMap:
35927 case ScriptType::ScriptedActiveSubscreen:
35928 case ScriptType::ScriptedPassiveSubscreen:
35929 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
35930 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
35931
35932 default: break;
35933 }
35934 invalid = 1; scommand = 0xFFFF;
35935 }
35936 if ( invalid ) break;
35937 ri->pc = sarg1;
35938 increment = false;
35939 break;
35940 }
35941 case GOTOR:
35942 {
35943 uint8_t invalid = 0;
35944 if(sarg1 < 0 )
35945 {
35946 const char* type_str = ScriptTypeToString(type);
35947 switch(type)
35948 {
35949 case ScriptType::FFC:
35950 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str() ,sarg1); break;
35951 case ScriptType::NPC:
35952 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
35953 case ScriptType::Lwpn:
35954 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
35955 case ScriptType::Ewpn:
35956 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
35957 case ScriptType::ItemSprite:
35958 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
35959 case ScriptType::Item:
35960 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
35961 case ScriptType::Global:
35962 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
35963 case ScriptType::Player:
35964 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
35965 case ScriptType::Screen:
35966 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
35967 case ScriptType::OnMap:
35968 case ScriptType::DMap:
35969 case ScriptType::ScriptedActiveSubscreen:
35970 case ScriptType::ScriptedPassiveSubscreen:
35971 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
35972 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
35973
35974 default: break;
35975 }
35976 invalid = 1; scommand = 0xFFFF;
35977 }
35978 if ( invalid ) break;
35979 ri->pc = (get_register(sarg1) / 10000) - 1;
35980 increment = false;
35981 }
35982 break;
35983
35984 case GOTOTRUE:
35985 if(ri->scriptflag & TRUEFLAG)
35986 {
35987 uint8_t invalid = 0;
35988 if(sarg1 < 0 )
35989 {
35990 const char* type_str = ScriptTypeToString(type);
35991 switch(type)
35992 {
35993 case ScriptType::FFC:
35994 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str(), sarg1); break;
35995 case ScriptType::NPC:
35996 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
35997 case ScriptType::Lwpn:
35998 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
35999 case ScriptType::Ewpn:
36000 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
36001 case ScriptType::ItemSprite:
36002 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
36003 case ScriptType::Item:
36004 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
36005 case ScriptType::Global:
36006 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
36007 case ScriptType::Player:
36008 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
36009 case ScriptType::Screen:
36010 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
36011 case ScriptType::OnMap:
36012 case ScriptType::DMap:
36013 case ScriptType::ScriptedActiveSubscreen:
36014 case ScriptType::ScriptedPassiveSubscreen:
36015 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
36016 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
36017
36018 default: break;
36019 }
36020 invalid = 1; scommand = 0xFFFF;
36021 }
36022 if ( invalid ) break;
36023 ri->pc = sarg1;
36024 increment = false;
36025 }
36026
36027 break;
36028
36029 case GOTOFALSE:
36030 if(!(ri->scriptflag & TRUEFLAG))
36031 {
36032 uint8_t invalid = 0;
36033 if(sarg1 < 0 )
36034 {
36035 const char* type_str = ScriptTypeToString(type);
36036 switch(type)
36037 {
36038 case ScriptType::FFC:
36039 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str(), sarg1); break;
36040 case ScriptType::NPC:
36041 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
36042 case ScriptType::Lwpn:
36043 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
36044 case ScriptType::Ewpn:
36045 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
36046 case ScriptType::ItemSprite:
36047 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
36048 case ScriptType::Item:
36049 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
36050 case ScriptType::Global:
36051 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
36052 case ScriptType::Player:
36053 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
36054 case ScriptType::Screen:
36055 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
36056 case ScriptType::OnMap:
36057 case ScriptType::DMap:
36058 case ScriptType::ScriptedActiveSubscreen:
36059 case ScriptType::ScriptedPassiveSubscreen:
36060 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
36061 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
36062
36063 default: break;
36064 }
36065 invalid = 1; scommand = 0xFFFF;
36066 }
36067 if ( invalid ) break;
36068 ri->pc = sarg1;
36069 increment = false;
36070 }
36071
36072 break;
36073
36074 case GOTOMORE:
36075 if(ri->scriptflag & MOREFLAG)
36076 {
36077 uint8_t invalid = 0;
36078 if(sarg1 < 0 )
36079 {
36080 const char* type_str = ScriptTypeToString(type);
36081 switch(type)
36082 {
36083 case ScriptType::FFC:
36084 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str(), sarg1); break;
36085 case ScriptType::NPC:
36086 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
36087 case ScriptType::Lwpn:
36088 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
36089 case ScriptType::Ewpn:
36090 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
36091 case ScriptType::ItemSprite:
36092 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
36093 case ScriptType::Item:
36094 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
36095 case ScriptType::Global:
36096 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
36097 case ScriptType::Player:
36098 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
36099 case ScriptType::Screen:
36100 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
36101 case ScriptType::OnMap:
36102 case ScriptType::DMap:
36103 case ScriptType::ScriptedActiveSubscreen:
36104 case ScriptType::ScriptedPassiveSubscreen:
36105 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
36106 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
36107
36108 default: break;
36109 }
36110 invalid = 1; scommand = 0xFFFF;
36111 }
36112 if ( invalid ) break;
36113 ri->pc = sarg1;
36114 increment = false;
36115 }
36116
36117 break;
36118
36119 case GOTOLESS:
36120 if(!(ri->scriptflag & MOREFLAG) || (!get_qr(qr_GOTOLESSNOTEQUAL) && (ri->scriptflag & TRUEFLAG)))
36121 {
36122 uint8_t invalid = 0;
36123 if(sarg1 < 0 )
36124 {
36125 const char* type_str = ScriptTypeToString(type);
36126 switch(type)
36127 {
36128 case ScriptType::FFC:
36129 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str(), sarg1); break;
36130 case ScriptType::NPC:
36131 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
36132 case ScriptType::Lwpn:
36133 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
36134 case ScriptType::Ewpn:
36135 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
36136 case ScriptType::ItemSprite:
36137 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
36138 case ScriptType::Item:
36139 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
36140 case ScriptType::Global:
36141 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
36142 case ScriptType::Player:
36143 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
36144 case ScriptType::Screen:
36145 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
36146 case ScriptType::OnMap:
36147 case ScriptType::DMap:
36148 case ScriptType::ScriptedActiveSubscreen:
36149 case ScriptType::ScriptedPassiveSubscreen:
36150 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
36151 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
36152
36153 default: break;
36154 }
36155 invalid = 1; scommand = 0xFFFF;
36156 }
36157 if ( invalid ) break;
36158 ri->pc = sarg1;
36159 increment = false;
36160 }
36161
36162 break;
36163
36164 case LOOP:
36165 {
36166 if(get_register(sarg2) > 0)
36167 {
36168 ri->pc = sarg1;
36169 increment = false;
36170 }
36171 else
36172 {
36173 set_register(sarg1, sarg1 - 1);
36174 }
36175 }
36176 break;
36177
36178 case RETURN:
36179 {
36180 if (script_funcrun)
36181 break; //handled below
36182 ri->pc = SH::read_stack(ri->sp) - 1;
36183 ++ri->sp;
36184 ri->sp &= MASK_SP;
36185 increment = false;
36186 break;
36187 }
36188
36189 case SETTRUE:
36190 set_register(sarg1, (ri->scriptflag & TRUEFLAG) ? 1 : 0);
36191 break;
36192
36193 case SETFALSE:
36194 set_register(sarg1, (ri->scriptflag & TRUEFLAG) ? 0 : 1);
36195 break;
36196
36197 case SETMORE:
36198 set_register(sarg1, (ri->scriptflag & MOREFLAG) ? 1 : 0);
36199 break;
36200
36201 case SETLESS:
36202 set_register(sarg1, (!(ri->scriptflag & MOREFLAG)
36203 || (ri->scriptflag & TRUEFLAG)) ? 1 : 0);
36204 break;
36205
36206 case SETTRUEI:
36207 set_register(sarg1, (ri->scriptflag & TRUEFLAG) ? 10000 : 0);
36208 break;
36209
36210 case SETFALSEI:
36211 set_register(sarg1, (ri->scriptflag & TRUEFLAG) ? 0 : 10000);
36212 break;
36213
36214 case SETMOREI:
36215 set_register(sarg1, (ri->scriptflag & MOREFLAG) ? 10000 : 0);
36216 break;
36217
36218 case SETLESSI:
36219 set_register(sarg1, (!(ri->scriptflag & MOREFLAG)
36220 || (ri->scriptflag & TRUEFLAG)) ? 10000 : 0);
36221 break;
36222
36223 case READPODARRAYR:
36224 {
36225 62716619 do_readpod(false);
36226 62716619 break;
36227 }
36228 case READPODARRAYV:
36229 {
36230 31889313 do_readpod(true);
36231 31889313 break;
36232 }
36233 case WRITEPODARRAYRR:
36234 {
36235 38156302 do_writepod(false,false);
36236 38156302 break;
36237 }
36238 case WRITEPODARRAYRV:
36239 {
36240 do_writepod(false,true);
36241 break;
36242 }
36243 case WRITEPODARRAYVR:
36244 {
36245 22093501 do_writepod(true,false);
36246 22093501 break;
36247 }
36248 case WRITEPODARRAYVV:
36249 {
36250 2928911 do_writepod(true,true);
36251 2928911 break;
36252 }
36253 case WRITEPODSTRING:
36254 {
36255 241209 do_writepodstr();
36256 241209 break;
36257 }
36258 case WRITEPODARRAY:
36259 {
36260 333 do_writepodarr();
36261 333 break;
36262 }
36263 case ZCLASS_CONSTRUCT:
36264 {
36265 do_constructclass(type,script,i);
36266 break;
36267 }
36268 case ZCLASS_READ:
36269 {
36270 do_readclass();
36271 break;
36272 }
36273 case ZCLASS_WRITE:
36274 {
36275 do_writeclass();
36276 break;
36277 }
36278 case ZCLASS_FREE:
36279 {
36280 do_freeclass();
36281 break;
36282 }
36283 case ZCLASS_OWN:
36284 {
36285 if(user_object* obj = checkObject(get_register(sarg1), true))
36286 {
36287 obj->own(type,i);
36288 }
36289 break;
36290 }
36291 case STARTDESTRUCTOR:
36292 {
36293 zprint2("STARTDESTRUCTOR: %s\n", sargstr->c_str());
36294 //This opcode's EXISTENCE indicates the first opcode
36295 //of a user_object destructor function.
36296 break;
36297 }
36298 case ZCLASS_GLOBALIZE:
36299 {
36300 if(user_object* obj = checkObject(get_register(sarg1), true))
36301 {
36302 obj->disown();
36303 }
36304 break;
36305 }
36306
36307 case NOT:
36308 do_not(false);
36309 break;
36310
36311 case COMPAREV:
36312 do_comp(true);
36313 break;
36314 case COMPAREV2:
36315 do_comp(true,true);
36316 break;
36317
36318 case COMPARER:
36319 do_comp(false);
36320 break;
36321
36322 case STRCMPR:
36323 do_internal_strcmp();
36324 break;
36325
36326 case STRICMPR:
36327 do_internal_stricmp();
36328 break;
36329
36330 case SETV:
36331 do_set(true, type, i);
36332 break;
36333
36334 case SETR:
36335 do_set(false, type, i);
36336 break;
36337
36338 case PUSHR:
36339 do_push(false);
36340 break;
36341
36342 case PUSHV:
36343 do_push(true);
36344 break;
36345
36346 case PEEK:
36347 70999 do_peek();
36348 70999 break;
36349 case PEEKATV:
36350 do_peekat(true);
36351 break;
36352 case POP:
36353 do_pop();
36354 break;
36355
36356 case POPARGS:
36357 do_pops();
36358 break;
36359
36360 case LOADI:
36361 do_loadi();
36362 break;
36363
36364 case STOREI:
36365 do_storei();
36366 break;
36367
36368 case LOADD:
36369 do_loadd();
36370 break;
36371
36372 case STORED:
36373 do_stored();
36374 break;
36375
36376 case LOAD1:
36377 do_loada(0);
36378 break;
36379
36380 case LOAD2:
36381 do_loada(1);
36382 break;
36383
36384 case SETA1:
36385 do_seta(0);
36386 break;
36387
36388 case SETA2:
36389 do_seta(1);
36390 break;
36391
36392 case ALLOCATEGMEMR:
36393 if(type == ScriptType::Global) do_allocatemem(false, false, type, i);
36394
36395 break;
36396
36397 case ALLOCATEGMEMV:
36398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(type == ScriptType::Global) do_allocatemem(true, false, type, i);
36399
36400 332 break;
36401
36402 case ALLOCATEMEMR:
36403 do_allocatemem(false, true, type, i);
36404 break;
36405
36406 case ALLOCATEMEMV:
36407 7024960 do_allocatemem(true, true, type, i);
36408 7024960 break;
36409
36410 case RESIZEARRAYR:
36411 do_resize_array();
36412 break;
36413 case OWNARRAYR:
36414 do_own_array(get_register(sarg1)/10000, type, i);
36415 break;
36416 case DESTROYARRAYR:
36417 do_destroy_array();
36418 break;
36419
36420 case DEALLOCATEMEMR:
36421 7000433 do_deallocatemem();
36422 7000433 break;
36423
36424 case SAVEGAMESTRUCTS:
36425 using_SRAM = 1;
36426 FFCore.do_savegamestructs(false,false);
36427 using_SRAM = 0;
36428 break;
36429 case READGAMESTRUCTS:
36430 using_SRAM = 1;
36431 FFCore.do_loadgamestructs(false,false);
36432 using_SRAM = 0;
36433 break;
36434 case ARRAYSIZE:
36435 294114413 do_arraysize();
36436 294114413 break;
36437 case ARRAYSIZEB:
36438 do_arraysize();
36439 break;
36440 case ARRAYSIZEF:
36441 do_arraysize();
36442 break;
36443 case ARRAYSIZEN:
36444 do_arraysize();
36445 break;
36446 case ARRAYSIZEI:
36447 do_arraysize();
36448 break;
36449 case ARRAYSIZEID:
36450 do_arraysize();
36451 break;
36452 case ARRAYSIZEL:
36453 do_arraysize();
36454 break;
36455 case ARRAYSIZEE:
36456 do_arraysize();
36457 break;
36458
36459 case GETFFCSCRIPT:
36460 227724 do_getffcscript();
36461 227724 break;
36462 case GETITEMSCRIPT:
36463 80 do_getitemscript();
36464 80 break;
36465
36466 case CASTBOOLI:
36467 do_boolcast(false);
36468 break;
36469
36470 case CASTBOOLF:
36471 do_boolcast(true);
36472 break;
36473
36474 case ADDV:
36475 do_add(true);
36476 break;
36477
36478 case ADDR:
36479 do_add(false);
36480 break;
36481
36482 case SUBV:
36483 do_sub(true);
36484 break;
36485 case SUBV2:
36486 do_sub(true,true);
36487 break;
36488
36489 case SUBR:
36490 do_sub(false);
36491 break;
36492
36493 case MULTV:
36494 do_mult(true);
36495 break;
36496
36497 case MULTR:
36498 do_mult(false);
36499 break;
36500
36501 case DIVV:
36502 do_div(true);
36503 break;
36504 case DIVV2:
36505 930 do_div(true,true);
36506 930 break;
36507
36508 case DIVR:
36509 do_div(false);
36510 break;
36511
36512 case MODV:
36513 do_mod(true);
36514 break;
36515 case MODV2:
36516 252 do_mod(true,true);
36517 252 break;
36518
36519 case MODR:
36520 do_mod(false);
36521 break;
36522
36523 case SINV:
36524 do_trig(true, 0);
36525 break;
36526
36527 case SINR:
36528 6164970 do_trig(false, 0);
36529 6164970 break;
36530
36531 case COSV:
36532 do_trig(true, 1);
36533 break;
36534
36535 case COSR:
36536 3205819 do_trig(false, 1);
36537 3205819 break;
36538
36539 case TANV:
36540 do_trig(true, 2);
36541 break;
36542
36543 case TANR:
36544 76 do_trig(false, 2);
36545 76 break;
36546
36547 case DEGTORAD:
36548 1263 do_degtorad();
36549 1263 break;
36550
36551 case RADTODEG:
36552 60936 do_radtodeg();
36553 60936 break;
36554
36555 case STRINGLENGTH:
36556 2629 FFCore.do_strlen(false);
36557 2629 break;
36558
36559 case ARCSINR:
36560 14918 do_asin(false);
36561 14918 break;
36562
36563 case ARCCOSR:
36564 do_acos(false);
36565 break;
36566
36567 case ARCTANR:
36568 864999 do_arctan();
36569 864999 break;
36570
36571 //Text ptr functions
36572 case FONTHEIGHTR:
36573 1259 do_fontheight();
36574 1259 break;
36575 case STRINGWIDTHR:
36576 13724 do_strwidth();
36577 13724 break;
36578 case CHARWIDTHR:
36579 37547 do_charwidth();
36580 37547 break;
36581 case MESSAGEWIDTHR:
36582 ri->d[rEXP1] = 10000* do_msgwidth(get_register(sarg1)/10000, "Text->MessageWidth()");
36583 break;
36584 case MESSAGEHEIGHTR:
36585 ri->d[rEXP1] = 10000* do_msgheight(get_register(sarg1)/10000, "Text->MessageHeight()");
36586 break;
36587 //
36588
36589 //String.h functions 2.55 Alpha 23
36590 1 case STRINGCOMPARE: FFCore.do_strcmp(); break;
36591 case STRINGICOMPARE: FFCore.do_stricmp(); break;
36592 1072 case STRINGCOPY: FFCore.do_strcpy(false,false); break;
36593 case ARRAYCOPY: FFCore.do_arraycpy(false,false); break;
36594 case STRINGNCOMPARE: FFCore.do_strncmp(); break;
36595 case STRINGNICOMPARE: FFCore.do_strnicmp(); break;
36596
36597 //More string.h functions, 19th May, 2019
36598 case XLEN: FFCore.do_xlen(false); break;
36599 case XTOI: FFCore.do_xtoi(false); break;
36600 case ILEN: FFCore.do_ilen(false); break;
36601 case ATOI: FFCore.do_atoi(false); break;
36602 case STRCSPN: FFCore.do_strcspn(); break;
36603 case STRSTR: FFCore.do_strstr(); break;
36604 case XTOA: FFCore.do_xtoa(); break;
36605 4761 case ITOA: FFCore.do_itoa(); break;
36606 case ITOACAT: FFCore.do_itoacat(); break;
36607 case STRCAT: FFCore.do_strcat(); break;
36608 case STRSPN: FFCore.do_strspn(); break;
36609 case STRCHR: FFCore.do_strchr(); break;
36610 case STRRCHR: FFCore.do_strrchr(); break;
36611 case XLEN2: FFCore.do_xlen2(); break;
36612 case XTOI2: FFCore.do_xtoi2(); break;
36613 case ILEN2: FFCore.do_ilen2(); break;
36614 case ATOI2: FFCore.do_atoi2(); break;
36615 case REMCHR2: FFCore.do_remchr2(); break;
36616 case UPPERTOLOWER: FFCore.do_UpperToLower(false); break;
36617 1 case LOWERTOUPPER: FFCore.do_LowerToUpper(false); break;
36618 case CONVERTCASE: FFCore.do_ConvertCase(false); break;
36619
36620 case GETNPCSCRIPT: FFCore.do_getnpcscript(); break;
36621 case GETCOMBOSCRIPT: FFCore.do_getcomboscript(); break;
36622 602 case GETLWEAPONSCRIPT: FFCore.do_getlweaponscript(); break;
36623 1275 case GETEWEAPONSCRIPT: FFCore.do_geteweaponscript(); break;
36624 case GETHEROSCRIPT: FFCore.do_getheroscript(); break;
36625 68 case GETGENERICSCRIPT: FFCore.do_getgenericscript(); break;
36626 case GETGLOBALSCRIPT: FFCore.do_getglobalscript(); break;
36627 105 case GETDMAPSCRIPT: FFCore.do_getdmapscript(); break;
36628 case GETSCREENSCRIPT: FFCore.do_getscreenscript(); break;
36629 31 case GETSPRITESCRIPT: FFCore.do_getitemspritescript(); break;
36630 case GETUNTYPEDSCRIPT: FFCore.do_getuntypedscript(); break;
36631 case GETSUBSCREENSCRIPT:FFCore.do_getsubscreenscript(); break;
36632 case GETNPCBYNAME: FFCore.do_getnpcbyname(); break;
36633 case GETITEMBYNAME: FFCore.do_getitembyname(); break;
36634 case GETCOMBOBYNAME: FFCore.do_getcombobyname(); break;
36635 case GETDMAPBYNAME: FFCore.do_getdmapbyname(); break;
36636
36637 case ABSR:
36638 do_abs(false);
36639 break;
36640
36641 case MINR:
36642 do_min(false);
36643 break;
36644
36645 case MINV:
36646 do_min(true);
36647 break;
36648
36649 case MAXR:
36650 do_max(false);
36651 break;
36652 case MAXV:
36653 do_max(true);
36654 break;
36655
36656 case MAXVARG:
36657 27143 FFCore.do_varg_max();
36658 27143 break;
36659 case MINVARG:
36660 72 FFCore.do_varg_min();
36661 72 break;
36662 case CHOOSEVARG:
36663 FFCore.do_varg_choose();
36664 break;
36665 case MAKEVARGARRAY:
36666 FFCore.do_varg_makearray(type,i);
36667 break;
36668
36669 case PUSHVARGV:
36670 27147 do_push_varg(true);
36671 27147 break;
36672 case PUSHVARGR:
36673 32662 do_push_varg(false);
36674 32662 break;
36675
36676 case RNDR:
36677 2703958 do_rnd(false);
36678 2703958 break;
36679
36680 case RNDV:
36681 do_rnd(true);
36682 break;
36683
36684 case SRNDR:
36685 do_srnd(false);
36686 break;
36687
36688 case SRNDV:
36689 do_srnd(true);
36690 break;
36691
36692 case SRNDRND:
36693 do_srndrnd();
36694 break;
36695
36696 case GETRTCTIMER:
36697 FFCore.getRTC(false);
36698 break;
36699 case GETRTCTIMEV:
36700 FFCore.getRTC(true);
36701 break;
36702
36703 case FACTORIAL:
36704 do_factorial(false);
36705 break;
36706
36707 case SQROOTV:
36708 do_sqroot(true);
36709 break;
36710
36711 case SQROOTR:
36712 2539388 do_sqroot(false);
36713 2539388 break;
36714
36715 case POWERR:
36716 77 do_power(false);
36717 77 break;
36718 case POWERV:
36719 do_power(true);
36720 break;
36721 case POWERV2:
36722 do_power(true,true);
36723 break;
36724
36725 case LPOWERR:
36726 do_lpower(false);
36727 break;
36728 case LPOWERV:
36729 do_lpower(true);
36730 break;
36731 case LPOWERV2:
36732 do_lpower(true,true);
36733 break;
36734
36735 case IPOWERR:
36736 do_ipower(false);
36737 break;
36738
36739 case IPOWERV:
36740 do_ipower(true);
36741 break;
36742
36743 case LOG10:
36744 27 do_log10(false);
36745 27 break;
36746
36747 case LOGE:
36748 20 do_naturallog(false);
36749 20 break;
36750
36751 case ANDR:
36752 do_and(false);
36753 break;
36754
36755 case ANDV:
36756 do_and(true);
36757 break;
36758
36759 case ORR:
36760 5580678 do_or(false);
36761 5580678 break;
36762
36763 case ORV:
36764 155486 do_or(true);
36765 155486 break;
36766
36767 case XORR:
36768 191294 do_xor(false);
36769 191294 break;
36770
36771 case XORV:
36772 3 do_xor(true);
36773 3 break;
36774
36775 case NANDR:
36776 do_nand(false);
36777 break;
36778
36779 case NANDV:
36780 do_nand(true);
36781 break;
36782
36783 case NORR:
36784 do_nor(false);
36785 break;
36786
36787 case NORV:
36788 do_nor(true);
36789 break;
36790
36791 case XNORR:
36792 do_xnor(false);
36793 break;
36794
36795 case XNORV:
36796 do_xnor(true);
36797 break;
36798
36799 case BITNOT:
36800 1427960 do_bitwisenot(false);
36801 1427960 break;
36802
36803 case LSHIFTR:
36804 62332728 do_lshift(false);
36805 62332728 break;
36806
36807 case LSHIFTV:
36808 511915 do_lshift(true);
36809 511915 break;
36810
36811 case RSHIFTR:
36812 20228359 do_rshift(false);
36813 20228359 break;
36814
36815 case RSHIFTV:
36816 377549 do_rshift(true);
36817 377549 break;
36818
36819 case ANDR32:
36820 34306 do_and32(false);
36821 34306 break;
36822
36823 case ANDV32:
36824 do_and32(true);
36825 break;
36826
36827 case ORR32:
36828 17 do_or32(false);
36829 17 break;
36830
36831 case ORV32:
36832 do_or32(true);
36833 break;
36834
36835 case XORR32:
36836 do_xor32(false);
36837 break;
36838
36839 case XORV32:
36840 do_xor32(true);
36841 break;
36842
36843 case BITNOT32:
36844 do_bitwisenot32(false);
36845 break;
36846
36847 case LSHIFTR32:
36848 22 do_lshift32(false);
36849 22 break;
36850
36851 case LSHIFTV32:
36852 do_lshift32(true);
36853 break;
36854
36855 case RSHIFTR32:
36856 34296 do_rshift32(false);
36857 34296 break;
36858
36859 case RSHIFTV32:
36860 do_rshift32(true);
36861 break;
36862
36863 case TRACER:
36864 3603 FFCore.do_trace(false);
36865 3603 break;
36866
36867 case TRACELR:
36868 FFCore.do_tracel(false);
36869 break;
36870
36871 case TRACEV:
36872 FFCore.do_trace(true);
36873 break;
36874
36875 case TRACE2R:
36876 FFCore.do_tracebool(false);
36877 break;
36878
36879 //Zap and Wavy Effects
36880 case FXWAVYR:
36881 FFCore.do_fx_wavy(false);
36882 break;
36883 case FXZAPR:
36884 FFCore.do_fx_zap(false);
36885 break;
36886 //Zap and Wavy Effects
36887 case FXWAVYV:
36888 FFCore.do_fx_wavy(true);
36889 break;
36890 case FXZAPV:
36891 FFCore.do_fx_zap(true);
36892 break;
36893 case GREYSCALER:
36894 FFCore.do_greyscale(false);
36895 break;
36896 case GREYSCALEV:
36897 FFCore.do_greyscale(true);
36898 break;
36899 case MONOCHROMER:
36900 FFCore.do_monochromatic(false);
36901 break;
36902 case MONOCHROMEV:
36903 FFCore.do_monochromatic(true);
36904 break;
36905
36906 case TRACE2V:
36907 FFCore.do_tracebool(true);
36908 break;
36909
36910 case TRACE3:
36911 FFCore.do_tracenl();
36912 break;
36913
36914 case TRACE4:
36915 2 FFCore.do_cleartrace();
36916 2 break;
36917
36918 case TRACE5:
36919 1 FFCore.do_tracetobase();
36920 1 break;
36921
36922 case TRACE6:
36923 384 FFCore.do_tracestring();
36924 384 break;
36925
36926 case PRINTFV:
36927 287 FFCore.do_printf(true, false);
36928 287 break;
36929 case SPRINTFV:
36930 11645 FFCore.do_sprintf(true, false);
36931 11645 break;
36932
36933 case PRINTFVARG:
36934 3322 FFCore.do_printf(true, true);
36935 3322 break;
36936 case SPRINTFVARG:
36937 FFCore.do_sprintf(true, true);
36938 break;
36939 case PRINTFA:
36940 FFCore.do_printfarr();
36941 break;
36942 case SPRINTFA:
36943 FFCore.do_printfarr();
36944 break;
36945 case ARRAYPUSH:
36946 {
36947 auto ptr = SH::read_stack(ri->sp + 2) / 10000;
36948 auto val = SH::read_stack(ri->sp + 1);
36949 auto indx = SH::read_stack(ri->sp + 0) / 10000;
36950 ArrayManager am(ptr);
36951 ri->d[rEXP1] = am.push(val,indx) ? 10000 : 0;
36952 break;
36953 }
36954 case ARRAYPOP:
36955 {
36956 auto ptr = SH::read_stack(ri->sp + 1) / 10000;
36957 auto indx = SH::read_stack(ri->sp + 0) / 10000;
36958 ArrayManager am(ptr);
36959 ri->d[rEXP1] = am.pop(indx);
36960 break;
36961 }
36962
36963 case BREAKPOINT:
36964 if( zasm_debugger )
36965 {
36966 FFCore.do_breakpoint();
36967 }
36968 break;
36969
36970 case WARP:
36971 do_warp(true);
36972 break;
36973
36974 case WARPR:
36975 79 do_warp(false);
36976 79 break;
36977
36978 case PITWARP:
36979 do_pitwarp(true);
36980 break;
36981
36982 case PITWARPR:
36983 126 do_pitwarp(false);
36984 126 break;
36985
36986 case BREAKSHIELD:
36987 do_breakshield();
36988 break;
36989
36990 case SELECTAWPNV:
36991 do_selectweapon(true, 1);
36992 break;
36993
36994 case SELECTAWPNR:
36995 5580 do_selectweapon(false, 1);
36996 5580 break;
36997
36998 case SELECTBWPNV:
36999 do_selectweapon(true, 0);
37000 break;
37001
37002 case SELECTBWPNR:
37003 5268 do_selectweapon(false, 0);
37004 5268 break;
37005
37006 case SELECTXWPNR:
37007 do_selectweapon(false, 2);
37008 break;
37009
37010 case SELECTYWPNR:
37011 do_selectweapon(false, 3);
37012 break;
37013
37014 case PLAYSOUNDR:
37015 170878 do_sfx(false);
37016 170878 break;
37017
37018 case PLAYSOUNDV:
37019 do_sfx(true);
37020 break;
37021
37022 case ADJUSTSFXVOLUMER: FFCore.do_adjustsfxvolume(false); break;
37023 case ADJUSTSFXVOLUMEV: FFCore.do_adjustsfxvolume(true); break;
37024 case ADJUSTVOLUMER: FFCore.do_adjustvolume(false); break;
37025 case ADJUSTVOLUMEV: FFCore.do_adjustvolume(true); break;
37026
37027 case TRIGGERSECRETR:
37028 FFScript::do_triggersecret(false);
37029 break;
37030
37031 case TRIGGERSECRETV:
37032 FFScript::do_triggersecret(true);
37033 break;
37034
37035 case PLAYMIDIR:
37036 63813 do_midi(false);
37037 63813 break;
37038
37039 case PLAYMIDIV:
37040 do_midi(true);
37041 break;
37042
37043 case PLAYENHMUSIC:
37044 79 do_enh_music(false);
37045 79 break;
37046
37047 case GETMUSICFILE:
37048 100 do_get_enh_music_filename(false);
37049 100 break;
37050
37051 case GETMUSICTRACK:
37052 5 do_get_enh_music_track(false);
37053 5 break;
37054
37055 case SETDMAPENHMUSIC:
37056 3750 do_set_dmap_enh_music(false);
37057 3750 break;
37058
37059 // Audio->
37060
37061 case ENDSOUNDR:
37062 stop_sfx(false);
37063 break;
37064
37065 case ENDSOUNDV:
37066 stop_sfx(true);
37067 break;
37068
37069 case PAUSESOUNDR:
37070 pause_sfx(false);
37071 break;
37072
37073 case PAUSESOUNDV:
37074 pause_sfx(true);
37075 break;
37076
37077 case RESUMESOUNDR:
37078 resume_sfx(false);
37079 break;
37080
37081 case RESUMESOUNDV:
37082 resume_sfx(true);
37083 break;
37084
37085
37086
37087 case PAUSESFX:
37088 {
37089 int32_t sound = ri->d[rINDEX]/10000;
37090 pause_sfx(sound);
37091
37092 }
37093 break;
37094
37095 case RESUMESFX:
37096 {
37097 int32_t sound = ri->d[rINDEX]/10000;
37098 resume_sfx(sound);
37099 }
37100 break;
37101
37102 case ADJUSTSFX:
37103 {
37104 do_sfx_ex(false);
37105 }
37106 break;
37107
37108 case PLAYSOUNDEX:
37109 {
37110 do_sfx_ex(true);
37111 }
37112 break;
37113
37114 case GETSFXCOMPLETION:
37115 {
37116 do_get_sfx_completion();
37117 }
37118 break;
37119
37120 case CONTINUESFX:
37121 {
37122 int32_t sound = ri->d[rINDEX]/10000;
37123 //Backend::sfx->cont_sfx(sound);
37124
37125 //! cont_sfx was not ported to the new back end!!!
37126 // I believe this restarted the loop.
37127 resume_sfx(sound);
37128 //What was the old instruction, again? Did it exist? -Z
37129 //continue_sfx(sound);
37130 }
37131 break;
37132
37133
37134 /*
37135 case STOPITEMSOUND:
37136 void stop_item_sfx(int32_t family)
37137 */
37138
37139 // Note: these have never worked.
37140 case PAUSEMUSIC:
37141 //What was the instruction prior to adding backends?
37142 //! The pauseAll() function pauses sfx, not music, so this instruction is not doing what I intended. -Z
37143 //Check AllOff() -Z
37144 //zcmusic_pause(ZCMUSIC* zcm, int32_t pause); is in zcmusic.h
37145 // midi_paused = true;
37146 //pause_all_sfx();
37147
37148 //Backend::sfx->pauseAll();
37149 break;
37150 case RESUMEMUSIC:
37151 //What was the instruction prior to adding backends?
37152 //Check AllOff() -Z
37153 //resume_all_sfx();
37154 // midi_paused = false;
37155 //Backend::sfx->resumeAll();
37156 break;
37157
37158 //!!! typecasting
37159 case LWPNARRPTR:
37160 case EWPNARRPTR:
37161 case ITEMARRPTR:
37162 case IDATAARRPTR:
37163 case FFCARRPTR:
37164 case BOOLARRPTR:
37165 case NPCARRPTR:
37166
37167 case LWPNARRPTR2:
37168 case EWPNARRPTR2:
37169 case ITEMARRPTR2:
37170 case IDATAARRPTR2:
37171 case FFCARRPTR2:
37172 case BOOLARRPTR2:
37173 case NPCARRPTR2:
37174 FFScript::do_typedpointer_typecast(false);
37175 break;
37176
37177 case MSGSTRR:
37178 173 do_message(false);
37179 173 break;
37180
37181 case MSGSTRV:
37182 do_message(true);
37183 break;
37184
37185 case ITEMNAME:
37186 2691 do_getitemname();
37187 2691 break;
37188
37189 case NPCNAME:
37190 do_getnpcname();
37191 break;
37192
37193 case NPCDATAGETNAME:
37194 FFCore.do_getnpcdata_getname();
37195 break;
37196
37197 case GETSAVENAME:
37198 10 do_getsavename();
37199 10 break;
37200
37201 case SETSAVENAME:
37202 do_setsavename();
37203 break;
37204
37205 case GETMESSAGE:
37206 3666 do_getmessage(false);
37207 3666 break;
37208 case SETMESSAGE:
37209 do_setmessage(false);
37210 break;
37211
37212 case GETDMAPNAME:
37213 do_getdmapname(false);
37214 break;
37215
37216 case GETDMAPTITLE:
37217 701 do_getdmaptitle(false);
37218 701 break;
37219
37220 case GETDMAPINTRO:
37221 do_getdmapintro(false);
37222 break;
37223
37224 case SETDMAPNAME:
37225 do_setdmapname(false);
37226 break;
37227
37228 case SETDMAPTITLE:
37229 do_setdmaptitle(false);
37230 break;
37231
37232 case SETDMAPINTRO:
37233 do_setdmapintro(false);
37234 break;
37235
37236 case LOADLWEAPONR:
37237 1201098 do_loadlweapon(false);
37238 1201098 break;
37239
37240 case LOADLWEAPONV:
37241 do_loadlweapon(true);
37242 break;
37243
37244 case LOADEWEAPONR:
37245 2753647 do_loadeweapon(false);
37246 2753647 break;
37247
37248 case LOADEWEAPONV:
37249 do_loadeweapon(true);
37250 break;
37251
37252 case LOADITEMR:
37253 136832 do_loaditem(false);
37254 136832 break;
37255
37256 case LOADITEMV:
37257 do_loaditem(true);
37258 break;
37259
37260 case LOADITEMDATAR:
37261 1816935 do_loaditemdata(false);
37262 1816935 break;
37263
37264 //New Datatypes
37265 case LOADSHOPR:
37266 FFScript::do_loadshopdata(false);
37267 break;
37268 case LOADSHOPV:
37269 FFScript::do_loadshopdata(true);
37270 break;
37271
37272 case LOADINFOSHOPR:
37273 FFScript::do_loadinfoshopdata(false);
37274 break;
37275 case LOADINFOSHOPV:
37276 FFScript::do_loadinfoshopdata(true);
37277 break;
37278 case LOADNPCDATAR:
37279 FFScript::do_loadnpcdata(false);
37280 break;
37281 case LOADNPCDATAV:
37282 FFScript::do_loadnpcdata(true);
37283 break;
37284
37285 case LOADCOMBODATAR:
37286 25412 FFScript::do_loadcombodata(false);
37287 25412 break;
37288 case LOADCOMBODATAV:
37289 FFScript::do_loadcombodata(true);
37290 break;
37291
37292 case LOADMAPDATAR:
37293 FFScript::do_loadmapdata(false);
37294 break;
37295 case LOADMAPDATAV:
37296 FFScript::do_loadmapdata(true);
37297 break;
37298 case LOADTMPSCR:
37299 403560 FFScript::do_loadmapdata_tempscr(false);
37300 403560 break;
37301 case LOADSCROLLSCR:
37302 177544 FFScript::do_loadmapdata_scrollscr(false);
37303 177544 break;
37304
37305 case LOADSPRITEDATAR:
37306 16 FFScript::do_loadspritedata(false);
37307 16 break;
37308 case LOADSPRITEDATAV:
37309 FFScript::do_loadspritedata(true);
37310 break;
37311
37312 case LOADSCREENDATAR:
37313 FFScript::do_loadscreendata(false);
37314 break;
37315 case LOADSCREENDATAV:
37316 FFScript::do_loadscreendata(true);
37317 break;
37318
37319 case LOADBITMAPDATAR:
37320 FFScript::do_loadbitmapid(false);
37321 break;
37322
37323
37324 case LOADBITMAPDATAV:
37325 FFScript::do_loadbitmapid(true);
37326 break;
37327
37328 //functions
37329 case LOADDMAPDATAR: //command
37330 802539 FFScript::do_loaddmapdata(false); break;
37331 case LOADDMAPDATAV: //command
37332 FFScript::do_loaddmapdata(true); break;
37333 case LOADSUBDATARV:
37334 FFScript::do_load_subscreendata(false, true); break;
37335 case SWAPSUBSCREENV:
37336 {
37337 auto ty = sarg1/10000;
37338 std::vector<ZCSubscreen>* vec = nullptr;
37339 switch(ty)
37340 {
37341 case sstACTIVE:
37342 vec = &subscreens_active;
37343 break;
37344 case sstPASSIVE:
37345 vec = &subscreens_passive;
37346 break;
37347 case sstOVERLAY:
37348 vec = &subscreens_overlay;
37349 break;
37350 default:
37351 Z_scripterrlog("Invalid Subscreen Type passed to ???: %d\n", ty);
37352 break;
37353 }
37354 if(vec)
37355 {
37356 auto& v = *vec;
37357 int p1 = SH::read_stack(ri->sp+1);
37358 int p2 = SH::read_stack(ri->sp+0);
37359 if(unsigned(p1) >= v.size())
37360 Z_scripterrlog("Invalid susbcr index '%d' passed to subscreendata->Swap*Pages()\n", p1);
37361 else if(unsigned(p2) >= v.size())
37362 Z_scripterrlog("Invalid susbcr index '%d' passed to subscreendata->Swap*Pages()\n", p2);
37363 else zc_swap(v[p1],v[p2]);
37364 }
37365 break;
37366 }
37367 case LOADDIRECTORYR:
37368 FFCore.do_loaddirectory(); break;
37369 case LOADSTACK:
37370 FFCore.do_loadstack(); break;
37371 case CREATEPALDATA:
37372 FFCore.do_create_paldata(); break;
37373 case CREATEPALDATACLR:
37374 FFCore.do_create_paldata_clr(); break;
37375 case MIXCLR:
37376 FFCore.do_mix_clr(); break;
37377 case CREATERGBHEX:
37378 FFCore.do_create_rgb_hex(); break;
37379 case CREATERGB:
37380 FFCore.do_create_rgb(); break;
37381 case CONVERTFROMRGB:
37382 FFCore.do_convert_from_rgb(); break;
37383 case CONVERTTORGB:
37384 FFCore.do_convert_to_rgb(); break;
37385 case PALDATALOADLEVEL:
37386 FFCore.do_paldata_load_level(); break;
37387 case PALDATALOADSPRITE:
37388 FFCore.do_paldata_load_sprite(); break;
37389 case PALDATALOADMAIN:
37390 FFCore.do_paldata_load_main(); break;
37391 case PALDATALOADCYCLE:
37392 FFCore.do_paldata_load_cycle(); break;
37393 case PALDATALOADBITMAP:
37394 FFCore.do_paldata_load_bitmap(); break;
37395 case PALDATAWRITELEVEL:
37396 FFCore.do_paldata_write_level(); break;
37397 case PALDATAWRITELEVELCS:
37398 FFCore.do_paldata_write_levelcset(); break;
37399 case PALDATAWRITESPRITE:
37400 FFCore.do_paldata_write_sprite(); break;
37401 case PALDATAWRITESPRITECS:
37402 FFCore.do_paldata_write_spritecset(); break;
37403 case PALDATAWRITEMAIN:
37404 FFCore.do_paldata_write_main(); break;
37405 case PALDATAWRITEMAINCS:
37406 FFCore.do_paldata_write_maincset(); break;
37407 case PALDATAWRITECYCLE:
37408 FFCore.do_paldata_write_cycle(); break;
37409 case PALDATAWRITECYCLECS:
37410 FFCore.do_paldata_write_cyclecset(); break;
37411 case PALDATAVALIDCLR:
37412 FFCore.do_paldata_colorvalid(); break;
37413 case PALDATACLEARCLR:
37414 FFCore.do_paldata_clearcolor(); break;
37415 case PALDATACLEARCSET:
37416 FFCore.do_paldata_clearcset(); break;
37417 case PALDATAMIX:
37418 FFCore.do_paldata_mix(); break;
37419 case PALDATAMIXCS:
37420 FFCore.do_paldata_mixcset(); break;
37421 case PALDATACOPY:
37422 FFCore.do_paldata_copy(); break;
37423 case PALDATACOPYCSET:
37424 FFCore.do_paldata_copycset(); break;
37425 case PALDATAFREE:
37426 if (user_paldata* pd = checkPalData(ri->paldataref, "Free()", true))
37427 {
37428 pd->clear();
37429 }
37430 break;
37431 case PALDATAOWN:
37432 if (user_paldata* pd = checkPalData(ri->paldataref, "Own()", false))
37433 {
37434 pd->own(type, i);
37435 }
37436 break;
37437 case LOADDROPSETR: //command
37438 FFCore.do_loaddropset(false); break;
37439 case LOADRNG: //command
37440 22 FFCore.do_loadrng(); break;
37441 case LOADBOTTLETYPE: //command
37442 FFCore.do_loadbottle(false); break;
37443 case LOADBSHOPDATA: //command
37444 FFCore.do_loadbottleshop(false); break;
37445
37446 case ITEMGETDISPLAYNAME: //command
37447 item_display_name(false); break;
37448 case ITEMSETDISPLAYNAME: //command
37449 item_display_name(true); break;
37450 case ITEMGETSHOWNNAME: //command
37451 item_shown_name(); break;
37452
37453 case DMAPDATAGETNAMER: //command
37454 FFScript::do_getDMapData_dmapname(false); break;
37455 case DMAPDATAGETNAMEV: //command
37456 FFScript::do_getDMapData_dmapname(true); break;
37457
37458 case DMAPDATASETNAMER: //command
37459 FFScript::do_setDMapData_dmapname(false); break;
37460 case DMAPDATASETNAMEV: //command
37461 FFScript::do_setDMapData_dmapname(true); break;
37462
37463
37464
37465 case DMAPDATAGETTITLER: //command
37466 FFScript::do_getDMapData_dmaptitle(false); break;
37467 case DMAPDATAGETTITLEV: //command
37468 FFScript::do_getDMapData_dmaptitle(true); break;
37469 case DMAPDATASETTITLER: //command
37470 FFScript::do_setDMapData_dmaptitle(false); break;
37471 case DMAPDATASETTITLEV: //command
37472 FFScript::do_setDMapData_dmaptitle(true); break;
37473
37474
37475 case DMAPDATAGETINTROR: //command
37476 FFScript::do_getDMapData_dmapintro(false); break;
37477 case DMAPDATAGETINTROV: //command
37478 FFScript::do_getDMapData_dmapintro(true); break;
37479 case DMAPDATANSETITROR: //command
37480 FFScript::do_setDMapData_dmapintro(false); break;
37481 case DMAPDATASETINTROV: //command
37482 FFScript::do_setDMapData_dmapintro(true); break;
37483
37484
37485 case DMAPDATAGETMUSICR: //command, string to load a music file
37486 FFScript::do_getDMapData_music(false); break;
37487 case DMAPDATAGETMUSICV: //command, string to load a music file
37488 FFScript::do_getDMapData_music(true); break;
37489 case DMAPDATASETMUSICR: //command, string to load a music file
37490 FFScript::do_setDMapData_music(false); break;
37491 case DMAPDATASETMUSICV: //command, string to load a music file
37492 FFScript::do_setDMapData_music(true); break;
37493
37494 case LOADMESSAGEDATAR: //COMMAND
37495 FFScript::do_loadmessagedata(false);
37496 break;
37497 case LOADMESSAGEDATAV: //COMMAND
37498 FFScript::do_loadmessagedata(false);
37499 break;
37500
37501
37502 case MESSAGEDATASETSTRINGR: //command
37503 FFScript::do_messagedata_setstring(false);
37504 break;
37505 case MESSAGEDATASETSTRINGV: //command
37506 FFScript::do_messagedata_setstring(false);
37507 break;
37508
37509 case MESSAGEDATAGETSTRINGR: //command
37510 FFScript::do_messagedata_getstring(false);
37511 break;
37512 case MESSAGEDATAGETSTRINGV: //command
37513 FFScript::do_messagedata_getstring(false);
37514 break;
37515 case LOADITEMDATAV:
37516 do_loaditemdata(true);
37517 break;
37518
37519 case LOADNPCBYSUID:
37520 12 FFCore.do_loadnpc_by_script_uid(false);
37521 12 break;
37522
37523 case LOADLWEAPONBYSUID:
37524 598 FFCore.do_loadlweapon_by_script_uid(false);
37525 598 break;
37526
37527 case LOADWEAPONCBYSUID:
37528 FFCore.do_loadeweapon_by_script_uid(false);
37529 break;
37530
37531 case LOADNPCR:
37532 15644354 do_loadnpc(false);
37533 15644354 break;
37534
37535 case LOADNPCV:
37536 do_loadnpc(true);
37537 break;
37538
37539 case CREATELWEAPONR:
37540 77278 do_createlweapon(false);
37541 77278 break;
37542
37543 case CREATELWEAPONV:
37544 do_createlweapon(true);
37545 break;
37546
37547 case CREATEEWEAPONR:
37548 131917 do_createeweapon(false);
37549 131917 break;
37550
37551 case CREATEEWEAPONV:
37552 do_createeweapon(true);
37553 break;
37554
37555 case CREATEITEMR:
37556 21343 do_createitem(false);
37557 21343 break;
37558
37559 case CREATEITEMV:
37560 do_createitem(true);
37561 break;
37562
37563 case CREATENPCR:
37564 2363 do_createnpc(false);
37565 2363 break;
37566
37567 case CREATENPCV:
37568 do_createnpc(true);
37569 break;
37570
37571 case ISVALIDARRAY:
37572 565 do_isvalidarray();
37573 565 break;
37574
37575 case ISVALIDITEM:
37576 27033 do_isvaliditem();
37577 27033 break;
37578
37579 case ISVALIDBITMAP:
37580 5 FFCore.do_isvalidbitmap();
37581 5 break;
37582
37583 case ISALLOCATEDBITMAP:
37584 43 FFCore.do_isallocatedbitmap();
37585 43 break;
37586
37587 case ISVALIDNPC:
37588 6266198 do_isvalidnpc();
37589 6266198 break;
37590
37591 case ISVALIDLWPN:
37592 593592 do_isvalidlwpn();
37593 593592 break;
37594
37595 case ISVALIDEWPN:
37596 122622 do_isvalidewpn();
37597 122622 break;
37598
37599 case LWPNMAKEANGULAR:
37600 do_lwpnmakeangular();
37601 break;
37602
37603 case EWPNMAKEANGULAR:
37604 do_ewpnmakeangular();
37605 break;
37606
37607 case LWPNMAKEDIRECTIONAL:
37608 do_lwpnmakedirectional();
37609 break;
37610
37611 case EWPNMAKEDIRECTIONAL:
37612 do_ewpnmakedirectional();
37613 break;
37614
37615 case LWPNUSESPRITER:
37616 15079 do_lwpnusesprite(false);
37617 15079 break;
37618
37619 case LWPNUSESPRITEV:
37620 do_lwpnusesprite(true);
37621 break;
37622
37623 case EWPNUSESPRITER:
37624 132144 do_ewpnusesprite(false);
37625 132144 break;
37626
37627 case EWPNUSESPRITEV:
37628 do_ewpnusesprite(true);
37629 break;
37630
37631 case CLEARSPRITESR:
37632 do_clearsprites(false);
37633 break;
37634
37635 case CLEARSPRITESV:
37636 do_clearsprites(true);
37637 break;
37638
37639 case ISSOLID:
37640 16274958 do_issolid();
37641 16274958 break;
37642
37643 case MAPDATAISSOLID:
37644 do_mapdataissolid();
37645 break;
37646
37647 case MAPDATAISSOLIDLYR:
37648 do_mapdataissolid_layer();
37649 break;
37650
37651 case ISSOLIDLAYER:
37652 do_issolid_layer();
37653 break;
37654
37655 case SETSIDEWARP:
37656 249 do_setsidewarp();
37657 249 break;
37658
37659 case SETTILEWARP:
37660 5 do_settilewarp();
37661 5 break;
37662
37663 case GETSIDEWARPDMAP:
37664 354940 do_getsidewarpdmap(false);
37665 354940 break;
37666
37667 case GETSIDEWARPSCR:
37668 do_getsidewarpscr(false);
37669 break;
37670
37671 case GETSIDEWARPTYPE:
37672 do_getsidewarptype(false);
37673 break;
37674
37675 case GETTILEWARPDMAP:
37676 354943 do_gettilewarpdmap(false);
37677 354943 break;
37678
37679 case GETTILEWARPSCR:
37680 3 do_gettilewarpscr(false);
37681 3 break;
37682
37683 case GETTILEWARPTYPE:
37684 3 do_gettilewarptype(false);
37685 3 break;
37686
37687 case LAYERSCREEN:
37688 12696160 do_layerscreen();
37689 12696160 break;
37690
37691 case LAYERMAP:
37692 16038753 do_layermap();
37693 16038753 break;
37694
37695 case SECRETS:
37696 60 do_triggersecrets();
37697 60 break;
37698
37699 case GETSCREENFLAGS:
37700 do_getscreenflags();
37701 break;
37702
37703 case GETSCREENEFLAGS:
37704 do_getscreeneflags();
37705 break;
37706
37707 case GRAPHICSGETPIXEL:
37708 FFCore.do_graphics_getpixel();
37709 break;
37710 case GRAPHICSCOUNTCOLOR:
37711 FFCore.do_bmpcollision();
37712 break;
37713
37714 case GETSCREENDOOR:
37715 do_getscreendoor();
37716 break;
37717
37718 case GETSCREENENEMY:
37719 do_getscreennpc();
37720 break;
37721
37722 //screendata and mapdata
37723 case SETSCREENENEMY:
37724 { //void SetScreenEnemy(int32_t map, int32_t screen, int32_t index, int32_t value);
37725 int32_t map = (ri->d[rINDEX2] / 10000) - 1;
37726 int32_t scrn = ri->d[rEXP1] / 10000;
37727 int32_t index = ri->d[rINDEX] / 10000;
37728 int32_t nn = ri->d[rEXP2]/10000;
37729
37730 // int32_t x;
37731
37732 // zprint("ri->d[rEXP2] is (%i), trying to use for '%s'\n", nn, "nn");
37733 // zprint("ri->d[rEXP1] is (%i), trying to use for '%s'\n", scrn, "scrn");
37734 // zprint("ri->d[rINDEX2] is (%i), trying to use for '%s'\n", map, "map");
37735 // zprint("ri->d[rINDEX] is (%i), trying to use for '%s'\n", index, "index");
37736
37737 if(BC::checkMapID(map, "Game->SetScreenEnemy(...map...)") != SH::_NoError ||
37738 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenEnemy(...screen...)") != SH::_NoError ||
37739 BC::checkBounds(index, 0, 9, "Game->SetScreenEnemy(...index...)") != SH::_NoError)
37740 return RUNSCRIPT_ERROR;
37741
37742 // if ( BC::checkBounds(nn, 0, 2, "Game->SetScreenEnemy(...enemy...)") != SH::_NoError) x = 1;
37743 // if ( BC::checkBounds(map, 20, 21, "Game->SetScreenEnemy(...map...)") != SH::_NoError) x = 2;
37744 FFScript::set_screenenemy(&TheMaps[map * MAPSCRS + scrn], index, nn);
37745 }
37746 break;
37747
37748 case SETSCREENDOOR:
37749 { //void SetScreenDoor(int32_t map, int32_t screen, int32_t index, int32_t value);
37750 int32_t map = (ri->d[rINDEX2] / 10000) - 1;
37751 int32_t scrn = ri->d[rEXP1] / 10000;
37752 int32_t index = ri->d[rINDEX] / 10000;
37753 int32_t nn = ri->d[rEXP2]/10000;
37754
37755 if(BC::checkMapID(map, "Game->SetScreenDoor(...map...)") != SH::_NoError ||
37756 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenDoor(...screen...)") != SH::_NoError ||
37757 BC::checkBounds(index, 0, 3, "Game->SetScreenDoor(...doorindex...)") != SH::_NoError)
37758 {
37759 return RUNSCRIPT_ERROR; break;
37760 }
37761 else
37762 {
37763 FFScript::set_screendoor(&TheMaps[map * MAPSCRS + scrn], index, nn);
37764 break;
37765 }
37766
37767 }
37768
37769 case GETSCREENLAYOP:
37770 do_getscreenLayerOpacity();
37771 break;
37772 case GETSCREENSECCMB:
37773 do_getscreenSecretCombo();
37774 break;
37775 case GETSCREENSECCST:
37776 do_getscreenSecretCSet();
37777 break;
37778 case GETSCREENSECFLG:
37779 do_getscreenSecretFlag();
37780 break;
37781 case GETSCREENLAYMAP:
37782 do_getscreenLayerMap();
37783 break;
37784 case GETSCREENLAYSCR:
37785 do_getscreenLayerscreen();
37786 break;
37787 case GETSCREENPATH:
37788 do_getscreenPath();
37789 break;
37790 case GETSCREENWARPRX:
37791 do_getscreenWarpReturnX();
37792 break;
37793 case GETSCREENWARPRY:
37794 do_getscreenWarpReturnY();
37795 break;
37796
37797 case COMBOTILE:
37798 2564 do_combotile(false);
37799 2564 break;
37800
37801 case DRAWLIGHT_CIRCLE:
37802 {
37803 static const int ARGS = 7;
37804 zfix cx = zslongToFix(SH::read_stack(ri->sp + (ARGS-1)));
37805 zfix cy = zslongToFix(SH::read_stack(ri->sp + (ARGS-2)));
37806 int radius = SH::read_stack(ri->sp + (ARGS-3));
37807 int transp_rad = SH::read_stack(ri->sp + (ARGS-4));
37808 int dith_rad = SH::read_stack(ri->sp + (ARGS-5));
37809 int dith_type = SH::read_stack(ri->sp + (ARGS-6));
37810 int dith_arg = SH::read_stack(ri->sp + (ARGS-7));
37811 if(radius >= 0) radius /= 10000;
37812 else radius = game->get_light_rad();
37813 if(!radius) break;
37814 if(transp_rad >= 0) transp_rad /= 10000;
37815 if(dith_rad >= 0) dith_rad /= 10000;
37816 if(dith_type >= 0) dith_type /= 10000;
37817 if(dith_arg >= 0) dith_arg /= 10000;
37818
37819 int32_t scrolldir = FFCore.ScrollingData[SCROLLDATA_DIR];
37820 int32_t scrollxoffs = 0, scrollyoffs = 0;
37821 switch(scrolldir)
37822 {
37823 case up:
37824 scrollyoffs = -176;
37825 break;
37826 case down:
37827 scrollyoffs = 176;
37828 break;
37829 case left:
37830 scrollxoffs = -256;
37831 break;
37832 case right:
37833 scrollxoffs = 256;
37834 break;
37835 }
37836
37837 doDarkroomCircle(cx,cy,radius,darkscr_bmp_curscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
37838 doDarkroomCircle(cx+scrollxoffs,cy+scrollyoffs,radius,darkscr_bmp_scrollscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
37839 break;
37840 }
37841 case DRAWLIGHT_SQUARE:
37842 {
37843 static const int ARGS = 7;
37844 zfix cx = zslongToFix(SH::read_stack(ri->sp + (ARGS-1)));
37845 zfix cy = zslongToFix(SH::read_stack(ri->sp + (ARGS-2)));
37846 int radius = SH::read_stack(ri->sp + (ARGS-3));
37847 int transp_rad = SH::read_stack(ri->sp + (ARGS-4));
37848 int dith_rad = SH::read_stack(ri->sp + (ARGS-5));
37849 int dith_type = SH::read_stack(ri->sp + (ARGS-6));
37850 int dith_arg = SH::read_stack(ri->sp + (ARGS-7));
37851 if(radius >= 0) radius /= 10000;
37852 else radius = game->get_light_rad();
37853 if(!radius) break;
37854 if(transp_rad >= 0) transp_rad /= 10000;
37855 if(dith_rad >= 0) dith_rad /= 10000;
37856 if(dith_type >= 0) dith_type /= 10000;
37857 if(dith_arg >= 0) dith_arg /= 10000;
37858
37859 int32_t scrolldir = FFCore.ScrollingData[SCROLLDATA_DIR];
37860 int32_t scrollxoffs = 0, scrollyoffs = 0;
37861 switch(scrolldir)
37862 {
37863 case up:
37864 scrollyoffs = -176;
37865 break;
37866 case down:
37867 scrollyoffs = 176;
37868 break;
37869 case left:
37870 scrollxoffs = -256;
37871 break;
37872 case right:
37873 scrollxoffs = 256;
37874 break;
37875 }
37876
37877 doDarkroomSquare(cx,cy,radius,darkscr_bmp_curscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
37878 doDarkroomSquare(cx+scrollxoffs,cy+scrollyoffs,radius,darkscr_bmp_scrollscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
37879 break;
37880 }
37881 case DRAWLIGHT_CONE:
37882 {
37883 static const int ARGS = 8;
37884 zfix cx = zslongToFix(SH::read_stack(ri->sp + (ARGS-1)));
37885 zfix cy = zslongToFix(SH::read_stack(ri->sp + (ARGS-2)));
37886 int dir = SH::read_stack(ri->sp + (ARGS-3)) / 10000;
37887 int radius = SH::read_stack(ri->sp + (ARGS-4));
37888 int transp_rad = SH::read_stack(ri->sp + (ARGS-5));
37889 int dith_rad = SH::read_stack(ri->sp + (ARGS-6));
37890 int dith_type = SH::read_stack(ri->sp + (ARGS-7));
37891 int dith_arg = SH::read_stack(ri->sp + (ARGS-8));
37892 if(radius >= 0) radius /= 10000;
37893 else radius = game->get_light_rad()*2;
37894 if(!radius) break;
37895 if(dir < 0) break;
37896 else dir = NORMAL_DIR(dir);
37897 if(transp_rad >= 0) transp_rad /= 10000;
37898 if(dith_rad >= 0) dith_rad /= 10000;
37899 if(dith_type >= 0) dith_type /= 10000;
37900 if(dith_arg >= 0) dith_arg /= 10000;
37901
37902 int32_t scrolldir = FFCore.ScrollingData[SCROLLDATA_DIR];
37903 int32_t scrollxoffs = 0, scrollyoffs = 0;
37904 switch(scrolldir)
37905 {
37906 case up:
37907 scrollyoffs = -176;
37908 break;
37909 case down:
37910 scrollyoffs = 176;
37911 break;
37912 case left:
37913 scrollxoffs = -256;
37914 break;
37915 case right:
37916 scrollxoffs = 256;
37917 break;
37918 }
37919
37920 doDarkroomCone(cx,cy,radius,dir,darkscr_bmp_curscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
37921 doDarkroomCone(cx+scrollxoffs,cy+scrollyoffs,radius,dir,darkscr_bmp_scrollscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
37922 break;
37923 }
37924
37925 case RECTR:
37926 case CIRCLER:
37927 case ARCR:
37928 case ELLIPSER:
37929 case LINER:
37930 case PUTPIXELR:
37931 case PIXELARRAYR:
37932 case TILEARRAYR:
37933 case LINESARRAY:
37934 case COMBOARRAYR:
37935 case DRAWTILER:
37936 case DRAWTILECLOAKEDR:
37937 case DRAWCOMBOR:
37938 case DRAWCOMBOCLOAKEDR:
37939 case DRAWCHARR:
37940 case DRAWINTR:
37941 case QUADR:
37942 case TRIANGLER:
37943 case QUAD3DR:
37944 case TRIANGLE3DR:
37945 case FASTTILER:
37946 case FASTCOMBOR:
37947 case DRAWSTRINGR:
37948 case DRAWSTRINGR2:
37949 case BMPDRAWSTRINGR2:
37950 case SPLINER:
37951 case BITMAPR:
37952 case BITMAPEXR:
37953 case DRAWLAYERR:
37954 case DRAWSCREENR:
37955 case POLYGONR:
37956 case FRAMER:
37957 37364177 do_drawing_command(scommand);
37958 37364177 break;
37959
37960 case BMPRECTR:
37961 case BMPCIRCLER:
37962 case BMPARCR:
37963 case BMPELLIPSER:
37964 case BMPLINER:
37965 case BMPSPLINER:
37966 case BMPPUTPIXELR:
37967 case BMPDRAWTILER:
37968 case BMPDRAWTILECLOAKEDR:
37969 case BMPDRAWCOMBOR:
37970 case BMPDRAWCOMBOCLOAKEDR:
37971 case BMPFASTTILER:
37972 case BMPFASTCOMBOR:
37973 case BMPDRAWCHARR:
37974 case BMPDRAWINTR:
37975 case BMPDRAWSTRINGR:
37976 case BMPQUADR:
37977 case BMPQUAD3DR:
37978 case BMPTRIANGLER:
37979 case BMPTRIANGLE3DR:
37980 case BMPPOLYGONR:
37981 case BMPDRAWLAYERR:
37982 case BMPDRAWLAYERSOLIDR:
37983 case BMPDRAWLAYERCFLAGR:
37984 case BMPDRAWLAYERCTYPER:
37985 case BMPDRAWLAYERCIFLAGR:
37986 case BMPDRAWLAYERSOLIDITYR:
37987 case BMPDRAWSCREENR:
37988 case BMPDRAWSCREENSOLIDR:
37989 case BMPDRAWSCREENSOLID2R:
37990 case BMPDRAWSCREENCOMBOFR:
37991 case BMPDRAWSCREENCOMBOIR:
37992 case BMPDRAWSCREENCOMBOTR:
37993 case BITMAPGETPIXEL:
37994 case BMPBLIT:
37995 case BMPBLITTO:
37996 case BMPMODE7:
37997 case WRITEBITMAP:
37998 case CLEARBITMAP:
37999 case BITMAPCLEARTOCOLOR:
38000 case BMPFRAMER:
38001 case BMPWRITETILE:
38002 case BMPDITHER:
38003 case BMPREPLCOLOR:
38004 case BMPSHIFTCOLOR:
38005 case BMPMASKDRAW:
38006 case BMPMASKDRAW2:
38007 case BMPMASKDRAW3:
38008 case BMPMASKBLIT:
38009 case BMPMASKBLIT2:
38010 case BMPMASKBLIT3:
38011 589788 do_drawing_command(scommand);
38012 589788 break;
38013 case READBITMAP:
38014 {
38015 int32_t bitref = SH::read_stack(ri->sp+2);
38016 if(user_bitmap* b = checkBitmap(bitref,"Read()",false,true))
38017 do_drawing_command(scommand);
38018 else //If the pointer isn't allocated, attempt to allocate it first
38019 {
38020 bitref = FFCore.get_free_bitmap();
38021 ri->d[rEXP2] = bitref; //Return to ptr
38022 if(bitref) SH::write_stack(ri->sp+2,bitref); //Write the ref, for the drawing command to read
38023 else break; //No ref allocated; don't enqueue the drawing command.
38024 do_drawing_command(scommand);
38025 }
38026 break;
38027 }
38028 case REGENERATEBITMAP:
38029 {
38030 26528 ri->d[rEXP2] = SH::read_stack(ri->sp+3);
38031
1/2
✓ Branch 0 taken 26528 times.
✗ Branch 1 not taken.
26528 if(user_bitmap* b = checkBitmap(ri->d[rEXP2],"Create()",false,true))
38032 26528 do_drawing_command(scommand);
38033 else //If the pointer isn't allocated
38034 {
38035 int32_t w = SH::read_stack(ri->sp) / 10000;
38036 int32_t h = SH::read_stack(ri->sp+1) / 10000;
38037 if ( get_qr(qr_OLDCREATEBITMAP_ARGS) )
38038 {
38039 //flip height and width
38040 h = h ^ w;
38041 w = h ^ w;
38042 h = h ^ w;
38043 }
38044
38045 ri->d[rEXP2] = FFCore.create_user_bitmap_ex(h,w,8); //Return to ptr
38046 }
38047 26528 break;
38048 }
38049
38050 case BITMAPFREE:
38051 {
38052 3512 FFCore.do_deallocate_bitmap();
38053 3512 break;
38054 }
38055
38056 case BITMAPOWN:
38057 {
38058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
146 if(FFCore.isSystemBitref(ri->bitmapref))
38059 break; //Don't attempt to own system bitmaps!
38060 146 user_bitmap* b = checkBitmap(ri->bitmapref, "Own()", false);
38061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
146 if(b)
38062 {
38063 146 b->own(type, i);
38064 146 }
38065 146 break;
38066 }
38067
38068 case OBJ_OWN_BITMAP:
38069 {
38070 int bmpid = get_register(sarg1);
38071 if(FFCore.isSystemBitref(bmpid))
38072 break; //Don't attempt to own system bitmaps!
38073 user_bitmap* b = checkBitmap(bmpid, nullptr, false);
38074 if(!b) break;
38075 ScriptType own_type = (ScriptType)sarg2;
38076 int32_t own_i = get_own_i(own_type);
38077 b->own(own_type,own_i);
38078 break;
38079 }
38080 case OBJ_OWN_PALDATA:
38081 {
38082 int palid = get_register(sarg1);
38083 user_paldata* pd = checkPalData(palid, nullptr, false);
38084 if(!pd) break;
38085 ScriptType own_type = (ScriptType)sarg2;
38086 int32_t own_i = get_own_i(own_type);
38087 pd->own(own_type,own_i);
38088 break;
38089 }
38090 case OBJ_OWN_FILE:
38091 {
38092 int fileid = get_register(sarg1);
38093 user_file* f = checkFile(fileid, nullptr, false);
38094 if(!f) break;
38095 ScriptType own_type = (ScriptType)sarg2;
38096 int32_t own_i = get_own_i(own_type);
38097 f->own(own_type,own_i);
38098 break;
38099 }
38100 case OBJ_OWN_DIR:
38101 {
38102 int dirid = get_register(sarg1);
38103 user_dir* dr = checkDir(dirid, nullptr, false);
38104 if(!dr) break;
38105 ScriptType own_type = (ScriptType)sarg2;
38106 int32_t own_i = get_own_i(own_type);
38107 dr->own(own_type,own_i);
38108 break;
38109 }
38110 case OBJ_OWN_STACK:
38111 {
38112 int stackid = get_register(sarg1);
38113 user_stack* st = checkStack(stackid, nullptr, false);
38114 if(!st) break;
38115 ScriptType own_type = (ScriptType)sarg2;
38116 int32_t own_i = get_own_i(own_type);
38117 st->own(own_type,own_i);
38118 break;
38119 }
38120 case OBJ_OWN_RNG:
38121 {
38122 int rngid = get_register(sarg1);
38123 user_rng* r = checkRNG(rngid, nullptr, false);
38124 if(!r) break;
38125 ScriptType own_type = (ScriptType)sarg2;
38126 int32_t own_i = get_own_i(own_type);
38127 r->own(own_type,own_i);
38128 break;
38129 }
38130 case OBJ_OWN_CLASS:
38131 {
38132 int classid = get_register(sarg1);
38133 user_object* obj = checkObject(classid, false);
38134 if(!obj) break;
38135 ScriptType own_type = (ScriptType)sarg2;
38136 int32_t own_i = get_own_i(own_type);
38137 obj->own(own_type,own_i);
38138 break;
38139 }
38140 case OBJ_OWN_ARRAY:
38141 {
38142 int arrid = get_register(sarg1)/10000;
38143 ScriptType own_type = (ScriptType)sarg2;
38144 int32_t own_i = get_own_i(own_type);
38145 do_own_array(arrid, own_type, own_i);
38146 break;
38147 }
38148
38149 case COPYTILEVV:
38150 do_copytile(true, true);
38151 break;
38152
38153 case COPYTILEVR:
38154 do_copytile(true, false);
38155 break;
38156
38157 case COPYTILERV:
38158 do_copytile(false, true);
38159 break;
38160
38161 case COPYTILERR:
38162 16962076 do_copytile(false, false);
38163 16962076 break;
38164
38165 case SWAPTILEVV:
38166 do_swaptile(true, true);
38167 break;
38168
38169 case SWAPTILEVR:
38170 do_swaptile(true, false);
38171 break;
38172
38173 case SWAPTILERV:
38174 do_swaptile(false, true);
38175 break;
38176
38177 case SWAPTILERR:
38178 do_swaptile(false, false);
38179 break;
38180
38181 case CLEARTILEV:
38182 do_cleartile(true);
38183 break;
38184
38185 case CLEARTILER:
38186 do_cleartile(false);
38187 break;
38188
38189 case OVERLAYTILEVV:
38190 do_overlaytile(true, true);
38191 break;
38192
38193 case OVERLAYTILEVR:
38194 do_overlaytile(true, false);
38195 break;
38196
38197 case OVERLAYTILERV:
38198 do_overlaytile(false, true);
38199 break;
38200
38201 case OVERLAYTILERR:
38202 57032 do_overlaytile(false, false);
38203 57032 break;
38204
38205 case FLIPROTTILEVV:
38206 do_fliprotatetile(true, true);
38207 break;
38208
38209 case FLIPROTTILEVR:
38210 do_fliprotatetile(true, false);
38211 break;
38212
38213 case FLIPROTTILERV:
38214 do_fliprotatetile(false, true);
38215 break;
38216
38217 case FLIPROTTILERR:
38218 do_fliprotatetile(false, false);
38219 break;
38220
38221 case GETTILEPIXELV:
38222 do_gettilepixel(true);
38223 break;
38224
38225 case GETTILEPIXELR:
38226 do_gettilepixel(false);
38227 break;
38228
38229 case SETTILEPIXELV:
38230 do_settilepixel(true);
38231 break;
38232
38233 case SETTILEPIXELR:
38234 do_settilepixel(false);
38235 break;
38236
38237 case SHIFTTILEVV:
38238 do_shifttile(true, true);
38239 break;
38240
38241 case SHIFTTILEVR:
38242 do_shifttile(true, false);
38243 break;
38244
38245 case SHIFTTILERV:
38246 do_shifttile(false, true);
38247 break;
38248
38249 case SHIFTTILERR:
38250 do_shifttile(false, false);
38251 break;
38252
38253 case SETRENDERTARGET:
38254 3535588 do_set_rendertarget(true);
38255 3535588 break;
38256
38257 case GAMEEND:
38258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( using_SRAM )
38259 {
38260 Z_scripterrlog("Cannot End Game while reading or writing to SRAM. Aborting End. /n");
38261 break;
38262 }
38263 1 Quit = qQUIT;
38264 1 skipcont = 1;
38265 1 scommand = 0xFFFF;
38266 1 break;
38267 case GAMERELOAD:
38268 if ( using_SRAM )
38269 {
38270 Z_scripterrlog("Cannot Reload Game while reading or writing to SRAM. Aborting Reload. /n");
38271 break;
38272 }
38273 Quit = qRELOAD;
38274 skipcont = 1;
38275 scommand = 0xFFFF;
38276 break;
38277 case GAMESETCUSTOMCURSOR:
38278 {
38279 int32_t bmpptr = SH::read_stack(ri->sp + 4);
38280 int fx = SH::read_stack(ri->sp + 3) / 10000;
38281 int fy = SH::read_stack(ri->sp + 2) / 10000;
38282 bool recolor = SH::read_stack(ri->sp + 1)!=0;
38283 bool scale = SH::read_stack(ri->sp + 0)!=0;
38284 if(user_bitmap* b = checkBitmap(bmpptr,nullptr,true))
38285 {
38286 custom_mouse(b->u_bmp,fx,fy,recolor,scale);
38287 }
38288 break;
38289 }
38290 case CURRENTITEMID:
38291 {
38292 int ity = SH::read_stack(ri->sp + 1) / 10000;
38293 int flags = SH::read_stack(ri->sp + 0) / 10000;
38294 bool checkcost = flags&0x01;
38295 bool checkjinx = flags&0x02;
38296 bool check_bunny = flags&0x04;
38297 ri->d[rEXP1] = current_item_id(ity,checkcost,checkjinx,check_bunny) * 10000;
38298 break;
38299 }
38300
38301 case GAMECONTINUE:
38302 if ( using_SRAM )
38303 {
38304 Z_scripterrlog("Cannot Continue Game while reading or writing to SRAM. Aborting Continue. /n");
38305 break;
38306 }
38307 reset_combo_animations();
38308 reset_combo_animations2();
38309
38310 Quit = qCONT;
38311 skipcont = 1;
38312 //cont_game();
38313 scommand = 0xFFFF;
38314 break;
38315
38316 case GAMESAVEQUIT:
38317 if ( using_SRAM )
38318 {
38319 Z_scripterrlog("Cannot Save Game while reading or writing to SRAM. Aborting Save. /n");
38320 break;
38321 }
38322 Quit = qSAVE;
38323 skipcont = 1;
38324 scommand =0xFFFF;
38325 break;
38326
38327 case GAMESAVECONTINUE:
38328 Quit = qSAVECONT;
38329 skipcont = 1;
38330 scommand =0xFFFF;
38331 break;
38332
38333 case SAVE:
38334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( using_SRAM )
38335 {
38336 Z_scripterrlog("Cannot Save Game while reading or writing to SRAM. Aborting Save. /n");
38337 break;
38338 }
38339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(scriptCanSave)
38340 {
38341 11 save_game(false);
38342 11 scriptCanSave=false;
38343 11 }
38344 11 break;
38345
38346 case SAVESCREEN:
38347 do_showsavescreen();
38348 break;
38349
38350 case SHOWF6SCREEN:
38351 onTryQuit();
38352 break;
38353
38354 case SAVEQUITSCREEN:
38355 save_game(false, 1);
38356 break;
38357
38358 //Not Implemented
38359 case ELLIPSE2:
38360 case FLOODFILL:
38361 break;
38362
38363 case SETCOLORB:
38364 case SETDEPTHB:
38365 case GETCOLORB:
38366 case GETDEPTHB:
38367 break;
38368
38369 case ENQUEUER:
38370 do_enqueue(false);
38371 break;
38372
38373 case ENQUEUEV:
38374 do_enqueue(true);
38375 break;
38376
38377 case DEQUEUE:
38378 do_dequeue(false);
38379 break;
38380
38381 //Visual Effects
38382 case WAVYIN:
38383 FFScript::do_wavyin();
38384 break;
38385 case WAVYOUT:
38386 FFScript::do_wavyout();
38387 break;
38388 case ZAPIN:
38389 FFScript::do_zapin();
38390 break;
38391 case ZAPOUT:
38392 FFScript::do_zapout();
38393 break;
38394 case OPENWIPE:
38395 {
38396 FFScript::do_openscreen();
38397 break;
38398 }
38399 case CLOSEWIPE:
38400 {
38401 FFScript::do_closescreen();
38402 break;
38403 }
38404 case OPENWIPESHAPE:
38405 {
38406 FFScript::do_openscreenshape();
38407 break;
38408 }
38409 case CLOSEWIPESHAPE:
38410 {
38411 FFScript::do_closescreenshape();
38412 break;
38413 }
38414
38415 //Monochrome
38416 case GREYSCALEON:
38417 setMonochrome(true);
38418 break;
38419 case GREYSCALEOFF:
38420 setMonochrome(false);
38421 break;
38422
38423 case TINT:
38424 {
38425 FFCore.Tint();
38426 break;
38427 }
38428
38429 case CLEARTINT:
38430 {
38431 FFCore.clearTint();
38432 break;
38433 }
38434
38435 case MONOHUE:
38436 {
38437 FFCore.gfxmonohue();
38438 break;
38439 }
38440
38441 case SCREENDOSPAWN:
38442 {
38443 ri->d[rEXP1] = scriptloadenemies() ? 10000 : 0;
38444 break;
38445 }
38446
38447 case SCRTRIGGERCOMBO:
38448 {
38449 int32_t lyr = get_register(sarg1) / 10000;
38450 int32_t pos = get_register(sarg2) / 10000;
38451 set_register(sarg1, do_trigger_combo(lyr,pos) ? 10000 : 0);
38452 break;
38453 }
38454
38455 case SWITCHNPC:
38456 {
38457 byte effect = vbound(get_register(sarg1)/10000, 0, 255);
38458 set_register(sarg1,0);
38459 if(Hero.switchhookclk) break; //Already switching!
38460 if(GuyH::loadNPC(ri->guyref, "npc->Switch()") == SH::_NoError)
38461 {
38462 switching_object = guys.spr(GuyH::getNPCIndex(ri->guyref));
38463 hooked_combopos = -1;
38464 hooked_layerbits = 0;
38465 switching_object->switch_hooked = true;
38466 Hero.doSwitchHook(effect);
38467 set_register(sarg1,10000);
38468 }
38469 break;
38470 }
38471
38472 case SWITCHITM:
38473 {
38474 byte effect = vbound(get_register(sarg1)/10000, 0, 255);
38475 set_register(sarg1,0);
38476 if(Hero.switchhookclk) break; //Already switching!
38477 if(ItemH::loadItem(ri->itemref, "item->Switch()") == SH::_NoError)
38478 {
38479 switching_object = items.spr(ItemH::getItemIndex(ri->itemref));
38480 hooked_combopos = -1;
38481 hooked_layerbits = 0;
38482 switching_object->switch_hooked = true;
38483 Hero.doSwitchHook(effect);
38484 set_register(sarg1,10000);
38485 }
38486 break;
38487 }
38488
38489 case SWITCHLW:
38490 {
38491 byte effect = vbound(get_register(sarg1)/10000, 0, 255);
38492 set_register(sarg1,0);
38493 if(Hero.switchhookclk) break; //Already switching!
38494 if(LwpnH::loadWeapon(ri->lwpn, "lweapon->Switch()") == SH::_NoError)
38495 {
38496 switching_object = Lwpns.spr(LwpnH::getLWeaponIndex(ri->lwpn));
38497 hooked_combopos = -1;
38498 hooked_layerbits = 0;
38499 switching_object->switch_hooked = true;
38500 Hero.doSwitchHook(effect);
38501 set_register(sarg1,10000);
38502 }
38503 break;
38504 }
38505
38506 case SWITCHEW:
38507 {
38508 byte effect = vbound(get_register(sarg1)/10000, 0, 255);
38509 set_register(sarg1,0);
38510 if(Hero.switchhookclk) break; //Already switching!
38511 if(EwpnH::loadWeapon(ri->ewpn, "eweapon->Switch()") == SH::_NoError)
38512 {
38513 switching_object = Ewpns.spr(EwpnH::getEWeaponIndex(ri->lwpn));
38514 hooked_combopos = -1;
38515 hooked_layerbits = 0;
38516 switching_object->switch_hooked = true;
38517 Hero.doSwitchHook(effect);
38518 set_register(sarg1,10000);
38519 }
38520 break;
38521 }
38522
38523 case SWITCHCMB:
38524 {
38525 int32_t pos = get_register(sarg1)/10000;
38526 set_register(sarg1,0);
38527 if(Hero.switchhookclk) break; //Already switching!
38528 if(unsigned(pos) > 176)
38529 break;
38530 switching_object = NULL;
38531 hooked_combopos = pos;
38532 hooked_layerbits = 0;
38533 Hero.doSwitchHook(get_register(sarg2)/10000);
38534 if(!hooked_layerbits) //failed
38535 Hero.reset_hookshot();
38536 else set_register(sarg1,10000); //success return
38537 break;
38538 }
38539
38540 case LINKWARPEXR:
38541 {
38542 16 FFCore.do_warp_ex(false);
38543 16 break;
38544 }
38545
38546 case KILLPLAYER:
38547 {
38548 Hero.kill(get_register(sarg1));
38549 break;
38550 }
38551
38552 case HEROMOVEXY:
38553 {
38554 zfix dx = zslongToFix(SH::read_stack(ri->sp + 4));
38555 zfix dy = zslongToFix(SH::read_stack(ri->sp + 3));
38556 bool kb = SH::read_stack(ri->sp + 2)!=0;
38557 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
38558 bool shove = SH::read_stack(ri->sp + 0)!=0;
38559 ri->d[rEXP1] = Hero.movexy(dx, dy, kb, ign_sv, shove) ? 10000 : 0;
38560 break;
38561 }
38562 case HEROCANMOVEXY:
38563 {
38564 zfix dx = zslongToFix(SH::read_stack(ri->sp + 4));
38565 zfix dy = zslongToFix(SH::read_stack(ri->sp + 3));
38566 bool kb = SH::read_stack(ri->sp + 2)!=0;
38567 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
38568 bool shove = SH::read_stack(ri->sp + 0)!=0;
38569 ri->d[rEXP1] = Hero.can_movexy(dx, dy, kb, ign_sv, shove) ? 10000 : 0;
38570 break;
38571 }
38572 case HEROMOVEATANGLE:
38573 {
38574 zfix degrees = zslongToFix(SH::read_stack(ri->sp + 4));
38575 zfix pxamnt = zslongToFix(SH::read_stack(ri->sp + 3));
38576 bool kb = SH::read_stack(ri->sp + 2)!=0;
38577 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
38578 bool shove = SH::read_stack(ri->sp + 0)!=0;
38579 ri->d[rEXP1] = Hero.moveAtAngle(degrees, pxamnt, kb, ign_sv, shove) ? 10000 : 0;
38580 break;
38581 }
38582 case HEROCANMOVEATANGLE:
38583 {
38584 zfix degrees = zslongToFix(SH::read_stack(ri->sp + 4));
38585 zfix pxamnt = zslongToFix(SH::read_stack(ri->sp + 3));
38586 bool kb = SH::read_stack(ri->sp + 2)!=0;
38587 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
38588 bool shove = SH::read_stack(ri->sp + 0)!=0;
38589 ri->d[rEXP1] = Hero.can_moveAtAngle(degrees, pxamnt, kb, ign_sv, shove) ? 10000 : 0;
38590 break;
38591 }
38592 case HEROMOVE:
38593 {
38594 int dir = SH::read_stack(ri->sp + 4)/10000;
38595 zfix pxamnt = zslongToFix(SH::read_stack(ri->sp + 3));
38596 bool kb = SH::read_stack(ri->sp + 2)!=0;
38597 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
38598 bool shove = SH::read_stack(ri->sp + 0)!=0;
38599 ri->d[rEXP1] = Hero.moveDir(dir, pxamnt, kb, ign_sv, shove) ? 10000 : 0;
38600 break;
38601 }
38602 case HEROCANMOVE:
38603 {
38604 int dir = SH::read_stack(ri->sp + 4)/10000;
38605 zfix pxamnt = zslongToFix(SH::read_stack(ri->sp + 3));
38606 bool kb = SH::read_stack(ri->sp + 2)!=0;
38607 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
38608 bool shove = SH::read_stack(ri->sp + 0)!=0;
38609 ri->d[rEXP1] = Hero.can_moveDir(dir, pxamnt, kb, ign_sv, shove) ? 10000 : 0;
38610 break;
38611 }
38612 case HEROLIFTRELEASE:
38613 {
38614 if(Hero.lift_wpn)
38615 {
38616 ri->d[rEXP1] = Hero.lift_wpn->getUID();
38617 Lwpns.add(Hero.lift_wpn);
38618 Hero.lift_wpn = nullptr;
38619 }
38620 else ri->d[rEXP1] = 0;
38621 break;
38622 }
38623 case HEROLIFTGRAB:
38624 {
38625 auto lwuid = SH::read_stack(ri->sp + 2);
38626 auto lifttime = SH::read_stack(ri->sp + 1)/10000;
38627 auto liftheight = zslongToFix(SH::read_stack(ri->sp + 0));
38628 if(weapon* wpn = checkLWpn(lwuid,"Hero->Lift()"))
38629 {
38630 Hero.lift(wpn, lifttime, liftheight);
38631 if(Lwpns.find(wpn) > -1)
38632 Lwpns.remove(wpn);
38633 if(type == ScriptType::Lwpn && lwuid == i)
38634 earlyretval = RUNSCRIPT_SELFREMOVE;
38635 }
38636 break;
38637 }
38638 case LOADPORTAL:
38639 {
38640 auto val = get_register(sarg1)/10000;
38641 if(val != -1)
38642 {
38643 portal* prt = (portal*)portals.spr(val);
38644 if(prt)
38645 val = prt->getUID();
38646 else
38647 {
38648 Z_scripterrlog("Tried to load invalid portal index '%d'\n", val);
38649 val = 0;
38650 }
38651 }
38652 ri->portalref = ri->d[rEXP1] = val;
38653 break;
38654 }
38655 case CREATEPORTAL:
38656 {
38657 portal* p = new portal();
38658 if(portals.add(p))
38659 ri->portalref = ri->d[rEXP1] = p->getUID();
38660 else
38661 {
38662 ri->portalref = ri->d[rEXP1] = 0;
38663 Z_scripterrlog("Unable to create new portal! Limit reached!\n");
38664 }
38665 break;
38666 }
38667 case LOADSAVPORTAL:
38668 {
38669 auto val = get_register(sarg1)/10000;
38670 savedportal* prt = checkSavedPortal(val,"Game->LoadSavedPortal");
38671 ri->saveportalref = ri->d[rEXP1] = prt ? val : 0;
38672 break;
38673 }
38674 case CREATESAVPORTAL:
38675 {
38676 if(game->user_portals.size() >= MAX_SAVED_PORTALS)
38677 {
38678 ri->saveportalref = ri->d[rEXP1] = 0;
38679 Z_scripterrlog("Cannot create any more Saved Portals! Remove some first!\n");
38680 break;
38681 }
38682 savedportal& ref = game->user_portals.emplace_back();
38683 ri->saveportalref = ri->d[rEXP1] = ref.getUID();
38684 break;
38685 }
38686 case PORTALREMOVE:
38687 {
38688 if(portal* p = checkPortal(ri->portalref, "Remove", true))
38689 {
38690 if(p == &mirror_portal)
38691 p->clear();
38692 else
38693 {
38694 auto id = portals.find(p);
38695 if(id > -1)
38696 portals.del(id,true);
38697 }
38698 }
38699 break;
38700 }
38701 case PORTALUSESPRITE:
38702 do_portalusesprite();
38703 break;
38704 case SAVEDPORTALREMOVE:
38705 {
38706 if(savedportal* sp = checkSavedPortal(ri->saveportalref, "Remove", true))
38707 {
38708 if(sp == &(game->saved_mirror_portal))
38709 sp->clear();
38710 else
38711 {
38712 //ensure all pointers to the object are cleared before deleting
38713 portals.forEach([&](sprite& spr)
38714 {
38715 portal* tmp = (portal*)&spr;
38716 if(sp->getUID() == tmp->saved_data)
38717 {
38718 tmp->saved_data = 0;
38719 }
38720 return false;
38721 });
38722 //delete the savedportal object from the vector
38723 for(auto it = game->user_portals.begin();
38724 it != game->user_portals.end();)
38725 {
38726 savedportal& tmp = *it;
38727 if(sp == &tmp)
38728 {
38729 game->user_portals.erase(it);
38730 break;
38731 }
38732 else ++it;
38733 }
38734 }
38735 }
38736 break;
38737 }
38738 case SAVEDPORTALGENERATE:
38739 {
38740 auto retval = 0;
38741 if(savedportal* sp = checkSavedPortal(ri->saveportalref, "Generate"))
38742 {
38743 retval = getPortalFromSaved(sp);
38744 if(!retval)
38745 {
38746 if(portal* p = loadportal(*sp))
38747 if(portals.add(p))
38748 retval = p->getUID();
38749 }
38750 }
38751 ri->d[rEXP1] = retval;
38752 break;
38753 }
38754
38755 case LINKEXPLODER:
38756 {
38757 int32_t mode = get_register(sarg1) / 10000;
38758 if ( (unsigned) mode > 2 )
38759 {
38760 Z_scripterrlog("Invalid mode (%d) passed to Player->Explode(int32_t mode)\n",mode);
38761 }
38762 else Hero.explode(mode);
38763 break;
38764 }
38765 case NPCEXPLODER:
38766 {
38767
38768 int32_t mode = get_register(sarg1) / 10000;
38769 al_trace("Called npc->Explode(%d), for enemy index %u\n", mode, ri->guyref);
38770 if ( (unsigned) mode > 2 )
38771 {
38772 Z_scripterrlog("Invalid mode (%d) passed to npc->Explode(int32_t mode)\n",mode);
38773 }
38774 else
38775 {
38776 if(GuyH::loadNPC(ri->guyref, "npc->Explode()") == SH::_NoError)
38777 {
38778 al_trace("npc->Explode() is loading the npc into a pointer.\n");
38779 //enemy *e = (enemy*)guys.spr(ri->guyref);
38780 al_trace("npc->Explode() is calling enemy::explode.\n");
38781 //(enemy *) guys.explode(eid);
38782 //e->explode(mode);
38783 //enemy *en=GuyH::getNPC();
38784 //en->stop_bgsfx(GuyH::getNPCIndex(ri->guyref));
38785 guys.spr(GuyH::getNPCIndex(ri->guyref))->explode(mode);
38786 }
38787 }
38788 break;
38789 }
38790
38791 case ITEMEXPLODER:
38792 {
38793
38794 int32_t mode = get_register(sarg1) / 10000;
38795 al_trace("Called item->Explode(%d), for item index %u\n", mode, ri->itemref);
38796 if ( (unsigned) mode > 2 )
38797 {
38798 Z_scripterrlog("Invalid mode (%d) passed to item->Explode(int32_t mode)\n",mode);
38799 }
38800 else
38801 {
38802 if(ItemH::loadItem(ri->itemref, "item->Explode()") == SH::_NoError)
38803 {
38804 items.spr(ItemH::getItemIndex(ri->itemref))->explode(mode);
38805 }
38806 }
38807 break;
38808 }
38809 case LWEAPONEXPLODER:
38810 {
38811
38812 int32_t mode = get_register(sarg1) / 10000;
38813 al_trace("Called lweapon->Explode(%d), for lweapon index %u\n", mode, ri->lwpn);
38814 if ( (unsigned) mode > 2 )
38815 {
38816 Z_scripterrlog("Invalid mode (%d) passed to lweapon->Explode(int32_t mode)\n",mode);
38817 }
38818 else
38819 {
38820 if(LwpnH::loadWeapon(ri->lwpn, "lweapon->Explode()") == SH::_NoError)
38821 {
38822 Lwpns.spr(LwpnH::getLWeaponIndex(ri->lwpn))->explode(mode);
38823 }
38824 }
38825 break;
38826 }
38827 case EWEAPONEXPLODER:
38828 {
38829
38830 int32_t mode = get_register(sarg1) / 10000;
38831 al_trace("Called eweapon->Explode(%d), for eweapon index %u\n", mode, ri->ewpn);
38832 if ( (unsigned) mode > 2 )
38833 {
38834 Z_scripterrlog("Invalid mode (%d) passed to eweapon->Explode(int32_t mode)\n",mode);
38835 }
38836 else
38837 {
38838 if(EwpnH::loadWeapon(ri->ewpn, "eweapon->Explode()") == SH::_NoError)
38839 {
38840 Ewpns.spr(EwpnH::getEWeaponIndex(ri->lwpn))->explode(mode);
38841 }
38842 }
38843 break;
38844 }
38845
38846 case BOTTLENAMEGET:
38847 {
38848 int32_t arrayptr = get_register(sarg1) / 10000;
38849 int32_t id = ri->bottletyperef-1;
38850 if(unsigned(id) > 63)
38851 {
38852 Z_scripterrlog("Invalid bottledata ID (%d) passed to bottledata->GetName().\n", id);
38853 break;
38854 }
38855
38856 if(ArrayH::setArray(arrayptr, QMisc.bottle_types[id].name) == SH::_Overflow)
38857 Z_scripterrlog("Array supplied to 'bottledata->GetName()' not large enough\n");
38858 break;
38859 }
38860 case BOTTLENAMESET:
38861 {
38862 int32_t arrayptr = get_register(sarg1) / 10000;
38863 int32_t id = ri->bottletyperef-1;
38864 if(unsigned(id) > 63)
38865 {
38866 Z_scripterrlog("Invalid bottledata ID (%d) passed to bottledata->SetName().\n", id+1);
38867 break;
38868 }
38869 string name;
38870 ArrayH::getString(arrayptr, name, 31);
38871 strcpy(QMisc.bottle_types[id].name, name.c_str());
38872 break;
38873 }
38874 case BSHOPNAMEGET:
38875 {
38876 int32_t arrayptr = get_register(sarg1) / 10000;
38877 int32_t id = ri->bottleshopref-1;
38878 if(unsigned(id) > 255)
38879 {
38880 Z_scripterrlog("Invalid bottleshopdata ID (%d) passed to bottleshopdata->GetName().\n", id+1);
38881 break;
38882 }
38883
38884 if(ArrayH::setArray(arrayptr, QMisc.bottle_shop_types[id].name) == SH::_Overflow)
38885 Z_scripterrlog("Array supplied to 'bottleshopdata->GetName()' not large enough\n");
38886 break;
38887 }
38888 case BSHOPNAMESET:
38889 {
38890 int32_t arrayptr = get_register(sarg1) / 10000;
38891 int32_t id = ri->bottleshopref;
38892 if(unsigned(id) > 255)
38893 {
38894 Z_scripterrlog("Invalid bottleshopdata ID (%d) passed to bottleshopdata->SetName().\n", id);
38895 break;
38896 }
38897 string name;
38898 ArrayH::getString(arrayptr, name, 31);
38899 strcpy(QMisc.bottle_shop_types[id].name, name.c_str());
38900 break;
38901 }
38902
38903 case RUNITEMSCRIPT:
38904 {
38905 15 int32_t itemid = ri->idata;
38906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(unsigned(itemid) > MAXITEMS) break;
38907 15 int32_t mode = get_register(sarg1) / 10000;
38908 // zprint("Trying to run the script on item: %d\n",itemid);
38909 // zprint("The script ID is: %d\n",itemsbuf[itemid].script);
38910 // zprint("Runitemscript mode is: %d\n", mode);
38911 15 auto& data = get_script_engine_data(ScriptType::Item, itemid);
38912
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 switch(mode)
38913 {
38914 case 0:
38915 {
38916 data.doscript = 4;
38917 break;
38918 }
38919 case 1:
38920 {
38921 if ( itemsbuf[itemid].script != 0 ) //&& !data.doscript )
38922 {
38923 if ( !data.doscript )
38924 {
38925 data.ref.Clear();
38926 data.doscript = 1;
38927 //ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[itemid].script, itemid);
38928 }
38929 else
38930 {
38931 //Emily, clear the stack here, clear refinfo, and set up to run again on the next frame from the beginning.
38932 }
38933 }
38934 break;
38935 }
38936 15 case 2:
38937 default:
38938 {
38939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if ( itemsbuf[itemid].script != 0 ) //&& !data.doscript )
38940 {
38941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if (data.doscript != 2 )data.doscript = 2;
38942 15 }
38943 15 break;
38944 }
38945 /*
38946 case 0:
38947 {
38948 data.doscript = 0;
38949 break;
38950 }
38951 default:
38952 {
38953
38954 if ( itemsbuf[itemid].script != 0 ) //&& !data.doscript )
38955 {
38956 //itemScriptData[itemid].Clear();
38957 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[itemid][q] = 0;
38958 //ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[itemid].script, itemid & 0xFFF);
38959 data.doscript = 2;
38960 }
38961 break;
38962 }
38963 */
38964 }
38965 15 break;
38966 }
38967
38968 //case NPCData
38969
38970 case GETNPCDATATILE: FFScript::getNPCData_tile(); break;
38971 case GETNPCDATAEHEIGHT: FFScript::getNPCData_e_height(); break;
38972 case GETNPCDATAFLAGS: FFScript::getNPCData_flags(); break;
38973 case GETNPCDATAFLAGS2: FFScript::getNPCData_flags2(); break;
38974 case GETNPCDATAWIDTH: FFScript::getNPCData_flags2(); break;
38975 case GETNPCDATAHEIGHT: FFScript::getNPCData_flags2(); break;
38976 case GETNPCDATASTILE: FFScript::getNPCData_s_tile(); break;
38977 case GETNPCDATASWIDTH: FFScript::getNPCData_s_width(); break;
38978 case GETNPCDATASHEIGHT: FFScript::getNPCData_s_height(); break;
38979 case GETNPCDATAETILE: FFScript::getNPCData_e_tile(); break;
38980 case GETNPCDATAEWIDTH: FFScript::getNPCData_e_width(); break;
38981 case GETNPCDATAHP: FFScript::getNPCData_hp(); break;
38982 case GETNPCDATAFAMILY: FFScript::getNPCData_family(); break;
38983 case GETNPCDATACSET: FFScript::getNPCData_cset(); break;
38984 case GETNPCDATAANIM: FFScript::getNPCData_anim(); break;
38985 case GETNPCDATAEANIM: FFScript::getNPCData_e_anim(); break;
38986 case GETNPCDATAFRAMERATE: FFScript::getNPCData_frate(); break;
38987 case GETNPCDATAEFRAMERATE: FFScript::getNPCData_e_frate(); break;
38988 case GETNPCDATATOUCHDMG: FFScript::getNPCData_dp(); break;
38989 case GETNPCDATAWPNDAMAGE: FFScript::getNPCData_wdp(); break;
38990 case GETNPCDATAWEAPON: FFScript::getNPCData_wdp(); break;
38991 case GETNPCDATARANDOM: FFScript::getNPCData_rate(); break;
38992 case GETNPCDATAHALT: FFScript::getNPCData_hrate(); break;
38993 case GETNPCDATASTEP: FFScript::getNPCData_step(); break;
38994 case GETNPCDATAHOMING: FFScript::getNPCData_homing(); break;
38995 case GETNPCDATAHUNGER: FFScript::getNPCData_grumble(); break;
38996 case GETNPCDATADROPSET: FFScript::getNPCData_item_set(); break;
38997 case GETNPCDATABGSFX: FFScript::getNPCData_bgsfx(); break;
38998 case GETNPCDATADEATHSFX: FFScript::getNPCData_deadsfx(); break;
38999 case GETNPCDATAXOFS: FFScript::getNPCData_xofs(); break;
39000 case GETNPCDATAYOFS: FFScript::getNPCData_yofs(); break;
39001 case GETNPCDATAZOFS: FFScript::getNPCData_zofs(); break;
39002 case GETNPCDATAHXOFS: FFScript::getNPCData_hxofs(); break;
39003 case GETNPCDATAHYOFS: FFScript::getNPCData_hyofs(); break;
39004 case GETNPCDATAHITWIDTH: FFScript::getNPCData_hxsz(); break;
39005 case GETNPCDATAHITHEIGHT: FFScript::getNPCData_hysz(); break;
39006 case GETNPCDATAHITZ: FFScript::getNPCData_hzsz(); break;
39007 case GETNPCDATATILEWIDTH: FFScript::getNPCData_txsz(); break;
39008 case GETNPCDATATILEHEIGHT: FFScript::getNPCData_tysz(); break;
39009 case GETNPCDATAWPNSPRITE: FFScript::getNPCData_wpnsprite(); break;
39010 //case GETNPCDATASCRIPTDEF: FFScript::getNPCData_scriptdefence(); break; //2.future cross-compat.
39011 case GETNPCDATADEFENSE: FFScript::getNPCData_defense(); break;
39012 case GETNPCDATASIZEFLAG: FFScript::getNPCData_SIZEflags(); break;
39013 case GETNPCDATAATTRIBUTE: FFScript::getNPCData_misc(); break;
39014 case GETNPCDATAHITSFX: FFScript::getNPCData_hitsfx(); break;
39015
39016 case SETNPCDATAFLAGS: FFScript::setNPCData_flags(); break;
39017 case SETNPCDATAFLAGS2: FFScript::setNPCData_flags2(); break;
39018 case SETNPCDATAWIDTH: FFScript::setNPCData_width(); break;
39019 case SETNPCDATAHEIGHT: FFScript::setNPCData_height(); break;
39020 case SETNPCDATASTILE: FFScript::setNPCData_s_tile(); break;
39021 case SETNPCDATASWIDTH: FFScript::setNPCData_s_width(); break;
39022 case SETNPCDATASHEIGHT: FFScript::setNPCData_s_height(); break;
39023 case SETNPCDATAETILE: FFScript::setNPCData_e_tile(); break;
39024 case SETNPCDATAEWIDTH: FFScript::setNPCData_e_width(); break;
39025 case SETNPCDATAHP: FFScript::setNPCData_hp(); break;
39026 case SETNPCDATAFAMILY: FFScript::setNPCData_family(); break;
39027 case SETNPCDATACSET: FFScript::setNPCData_cset(); break;
39028 case SETNPCDATAANIM: FFScript::setNPCData_anim(); break;
39029 case SETNPCDATAEANIM: FFScript::setNPCData_e_anim(); break;
39030 case SETNPCDATAFRAMERATE: FFScript::setNPCData_frate(); break;
39031 case SETNPCDATAEFRAMERATE: FFScript::setNPCData_e_frate(); break;
39032 case SETNPCDATATOUCHDMG: FFScript::setNPCData_dp(); break;
39033 case SETNPCDATAWPNDAMAGE: FFScript::setNPCData_wdp(); break;
39034 case SETNPCDATAWEAPON: FFScript::setNPCData_weapon(); break;
39035 case SETNPCDATARANDOM: FFScript::setNPCData_rate(); break;
39036 case SETNPCDATAHALT: FFScript::setNPCData_hrate(); break;
39037 case SETNPCDATASTEP: FFScript::setNPCData_step(); break;
39038 case SETNPCDATAHOMING: FFScript::setNPCData_homing(); break;
39039 case SETNPCDATAHUNGER: FFScript::setNPCData_grumble(); break;
39040 case SETNPCDATADROPSET: FFScript::setNPCData_item_set(); break;
39041 case SETNPCDATABGSFX: FFScript::setNPCData_bgsfx(); break;
39042 case SETNPCDATADEATHSFX: FFScript::setNPCData_hitsfx(); break;
39043 case SETNPCDATAXOFS: FFScript::setNPCData_xofs(); break;
39044 case SETNPCDATAYOFS: FFScript::setNPCData_yofs(); break;
39045 case SETNPCDATAZOFS: FFScript::setNPCData_zofs(); break;
39046 case SETNPCDATAHXOFS: FFScript::setNPCData_hxofs(); break;
39047 case SETNPCDATAHYOFS: FFScript::setNPCData_hyofs(); break;
39048 case SETNPCDATAHITWIDTH: FFScript::setNPCData_hxsz(); break;
39049 case SETNPCDATAHITHEIGHT: FFScript::setNPCData_hysz(); break;
39050 case SETNPCDATAHITZ: FFScript::setNPCData_hzsz(); break;
39051 case SETNPCDATATILEWIDTH: FFScript::setNPCData_txsz(); break;
39052 case SETNPCDATATILEHEIGHT: FFScript::setNPCData_tysz(); break;
39053 case SETNPCDATAWPNSPRITE: FFScript::setNPCData_wpnsprite(); break;
39054 case SETNPCDATAHITSFX: FFScript::setNPCData_hitsfx(); break;
39055 case SETNPCDATATILE: FFScript::setNPCData_tile(); break;
39056 case SETNPCDATAEHEIGHT: FFScript::setNPCData_e_height(); break;
39057
39058
39059
39060
39061
39062
39063 //case SETNPCDATASCRIPTDEF : FFScript::setNPCData_scriptdefence(); break;
39064 case SETNPCDATADEFENSE : FFScript::setNPCData_defense(ri->d[rEXP1]); break;
39065 case SETNPCDATASIZEFLAG : FFScript::setNPCData_SIZEflags(ri->d[rEXP1]); break;
39066 case SETNPCDATAATTRIBUTE : FFScript::setNPCData_misc(ri->d[rEXP1]); break;
39067
39068
39069 //ComboData
39070
39071 case GCDBLOCKENEM: FFScript::getComboData_block_enemies(); break;
39072 case GCDBLOCKHOLE: FFScript::getComboData_block_hole(); break;
39073 case GCDBLOCKTRIG: FFScript::getComboData_block_trigger(); break;
39074 case GCDCONVEYSPDX: FFScript::getComboData_conveyor_x_speed(); break;
39075 case GCDCONVEYSPDY: FFScript::getComboData_conveyor_y_speed(); break;
39076 case GCDCREATEENEM: FFScript::getComboData_create_enemy(); break;
39077 case GCDCREATEENEMWH: FFScript::getComboData_create_enemy_when(); break;
39078 case GCDCREATEENEMCH: FFScript::getComboData_create_enemy_change(); break;
39079 case GCDDIRCHTYPE: FFScript::getComboData_directional_change_type(); break;
39080 case GCDDISTCHTILES: FFScript::getComboData_distance_change_tiles(); break;
39081 case GCDDIVEITEM: FFScript::getComboData_dive_item(); break;
39082 case GCDDOCK: FFScript::getComboData_dock(); break;
39083 case GCDFAIRY: FFScript::getComboData_fairy(); break;
39084 case GCDFFCOMBOATTRIB: FFScript::getComboData_ff_combo_attr_change(); break;
39085 case GCDFOOTDECOTILE: FFScript::getComboData_foot_decorations_tile(); break;
39086 case GCDFOOTDECOTYPE: FFScript::getComboData_foot_decorations_type(); break;
39087 case GCDHOOKSHOTGRAB: FFScript::getComboData_hookshot_grab_point(); break;
39088 case GCDLADDERPASS: FFScript::getComboData_ladder_pass(); break;
39089 case GCDLOCKBLOCKTYPE: FFScript::getComboData_lock_block_type(); break;
39090 case GCDLOCKBLOCKCHANGE: FFScript::getComboData_lock_block_change(); break;
39091 case GCDMAGICMIRRORTYPE: FFScript::getComboData_magic_mirror_type(); break;
39092 case GCDMODIFYHPAMOUNT: FFScript::getComboData_modify_hp_amount(); break;
39093 case GCDMODIFYHPDELAY: FFScript::getComboData_modify_hp_delay(); break;
39094 case GCDMODIFYHPTYPE: FFScript::getComboData_modify_hp_type(); break;
39095 case GCDMODIFYMPAMOUNT: FFScript::getComboData_modify_mp_amount(); break;
39096 case GCDMODIFYMPDELAY: FFScript::getComboData_modify_mp_delay(); break;
39097 case GCDMODIFYMPTYPE: FFScript::getComboData_modify_mp_type(); break;
39098 case GCDNOPUSHBLOCKS: FFScript::getComboData_no_push_blocks(); break;
39099 case GCDOVERHEAD: FFScript::getComboData_overhead(); break;
39100 case GCDPLACEENEMY: FFScript::getComboData_place_enemy(); break;
39101 case GCDPUSHDIR: FFScript::getComboData_push_direction(); break;
39102 case GCDPUSHWEIGHT: FFScript::getComboData_push_weight(); break;
39103 case GCDPUSHWAIT: FFScript::getComboData_push_wait(); break;
39104 case GCDPUSHED: FFScript::getComboData_pushed(); break;
39105 case GCDRAFT: FFScript::getComboData_raft(); break;
39106 case GCDRESETROOM: FFScript::getComboData_reset_room(); break;
39107 case GCDSAVEPOINT: FFScript::getComboData_save_point_type(); break;
39108 case GCDSCREENFREEZE: FFScript::getComboData_screen_freeze_type(); break;
39109 case GCDSECRETCOMBO: FFScript::getComboData_secret_combo(); break;
39110 case GCDSINGULAR: FFScript::getComboData_singular(); break;
39111 case GCDSLOWMOVE: FFScript::getComboData_slow_movement(); break;
39112 case GCDSTATUE: FFScript::getComboData_statue_type(); break;
39113 case GCDSTEPTYPE: FFScript::getComboData_step_type(); break;
39114 case GCDSTEPCHANGETO: FFScript::getComboData_step_change_to(); break;
39115 case GCDSTRIKEREMNANTS: FFScript::getComboData_strike_remnants(); break;
39116 case GCDSTRIKEREMNANTSTYPE: FFScript::getComboData_strike_remnants_type(); break;
39117 case GCDSTRIKECHANGE: FFScript::getComboData_strike_change(); break;
39118 case GCDSTRIKECHANGEITEM: FFScript::getComboData_strike_item(); break;
39119 case GCDTOUCHITEM: FFScript::getComboData_touch_item(); break;
39120 case GCDTOUCHSTAIRS: FFScript::getComboData_touch_stairs(); break;
39121 case GCDTRIGGERTYPE: FFScript::getComboData_trigger_type(); break;
39122 case GCDTRIGGERSENS: FFScript::getComboData_trigger_sensitive(); break;
39123 case GCDWARPTYPE: FFScript::getComboData_warp_type(); break;
39124 case GCDWARPSENS: FFScript::getComboData_warp_sensitive(); break;
39125 case GCDWARPDIRECT: FFScript::getComboData_warp_direct(); break;
39126 case GCDWARPLOCATION: FFScript::getComboData_warp_location(); break;
39127 case GCDWATER: FFScript::getComboData_water(); break;
39128 case GCDWHISTLE: FFScript::getComboData_whistle(); break;
39129 case GCDWINGAME: FFScript::getComboData_win_game(); break;
39130 case GCDBLOCKWEAPLVL: FFScript::getComboData_block_weapon_lvl(); break;
39131 case GCDTILE: FFScript::getComboData_tile(); break;
39132 case GCDFLIP: FFScript::getComboData_flip(); break;
39133 case GCDWALK: FFScript::getComboData_walk(); break;
39134 case GCDTYPE: FFScript::getComboData_type(); break;
39135 case GCDCSETS: FFScript::getComboData_csets(); break;
39136 case GCDFOO: break;
39137 case GCDFRAMES: FFScript::getComboData_frames(); break;
39138 case GCDSPEED: FFScript::getComboData_speed(); break;
39139 case GCDNEXTCOMBO: FFScript::getComboData_nextcombo(); break;
39140 case GCDNEXTCSET: FFScript::getComboData_nextcset(); break;
39141 case GCDFLAG: FFScript::getComboData_flag(); break;
39142 case GCDSKIPANIM: FFScript::getComboData_skipanim(); break;
39143 case GCDNEXTTIMER: FFScript::getComboData_nexttimer(); break;
39144 case GCDSKIPANIMY: FFScript::getComboData_skipanimy(); break;
39145 case GCDANIMFLAGS: FFScript::getComboData_animflags(); break;
39146 case GCDBLOCKWEAPON: FFScript::getComboData_block_weapon(); break;
39147 case GCDEXPANSION: FFScript::getComboData_expansion(); break;
39148 case GCDSTRIKEWEAPONS: FFScript::getComboData_strike_weapons(); break;
39149 case SCDBLOCKENEM: FFScript::setComboData_block_enemies(); break;
39150 case SCDBLOCKHOLE: FFScript::setComboData_block_hole(); break;
39151 case SCDBLOCKTRIG: FFScript::setComboData_block_trigger(); break;
39152 case SCDCONVEYSPDX: FFScript::setComboData_conveyor_x_speed(); break;
39153 case SCDCONVEYSPDY: FFScript::setComboData_conveyor_y_speed(); break;
39154 case SCDCREATEENEM: FFScript::setComboData_create_enemy(); break;
39155 case SCDCREATEENEMWH: FFScript::setComboData_create_enemy_when(); break;
39156 case SCDCREATEENEMCH: FFScript::setComboData_create_enemy_change(); break;
39157 case SCDDIRCHTYPE: FFScript::setComboData_directional_change_type(); break;
39158 case SCDDISTCHTILES: FFScript::setComboData_distance_change_tiles(); break;
39159 case SCDDIVEITEM: FFScript::setComboData_dive_item(); break;
39160 case SCDDOCK: FFScript::setComboData_dock(); break;
39161 case SCDFAIRY: FFScript::setComboData_fairy(); break;
39162 case SCDFFCOMBOATTRIB: FFScript::setComboData_ff_combo_attr_change(); break;
39163 case SCDFOOTDECOTILE: FFScript::setComboData_foot_decorations_tile(); break;
39164 case SCDFOOTDECOTYPE: FFScript::setComboData_foot_decorations_type(); break;
39165 case SCDHOOKSHOTGRAB: FFScript::setComboData_hookshot_grab_point(); break;
39166 case SCDLADDERPASS: FFScript::setComboData_ladder_pass(); break;
39167 case SCDLOCKBLOCKTYPE: FFScript::setComboData_lock_block_type(); break;
39168 case SCDLOCKBLOCKCHANGE: FFScript::setComboData_lock_block_change(); break;
39169 case SCDMAGICMIRRORTYPE: FFScript::setComboData_magic_mirror_type(); break;
39170 case SCDMODIFYHPAMOUNT: FFScript::setComboData_modify_hp_amount(); break;
39171 case SCDMODIFYHPDELAY: FFScript::setComboData_modify_hp_delay(); break;
39172 case SCDMODIFYHPTYPE: FFScript::setComboData_modify_hp_type(); break;
39173 case SCDMODIFYMPAMOUNT: FFScript::setComboData_modify_mp_amount(); break;
39174 case SCDMODIFYMPDELAY: FFScript::setComboData_modify_mp_delay(); break;
39175 case SCDMODIFYMPTYPE: FFScript::setComboData_modify_mp_type(); break;
39176 case SCDNOPUSHBLOCKS: FFScript::setComboData_no_push_blocks(); break;
39177 case SCDOVERHEAD: FFScript::setComboData_overhead(); break;
39178 case SCDPLACEENEMY: FFScript::setComboData_place_enemy(); break;
39179 case SCDPUSHDIR: FFScript::setComboData_push_direction(); break;
39180 case SCDPUSHWEIGHT: FFScript::setComboData_push_weight(); break;
39181 case SCDPUSHWAIT: FFScript::setComboData_push_wait(); break;
39182 case SCDPUSHED: FFScript::setComboData_pushed(); break;
39183 case SCDRAFT: FFScript::setComboData_raft(); break;
39184 case SCDRESETROOM: FFScript::setComboData_reset_room(); break;
39185 case SCDSAVEPOINT: FFScript::setComboData_save_point_type(); break;
39186 case SCDSCREENFREEZE: FFScript::setComboData_screen_freeze_type(); break;
39187 case SCDSECRETCOMBO: FFScript::setComboData_secret_combo(); break;
39188 case SCDSINGULAR: FFScript::setComboData_singular(); break;
39189 case SCDSLOWMOVE: FFScript::setComboData_slow_movement(); break;
39190 case SCDSTATUE: FFScript::setComboData_statue_type(); break;
39191 case SCDSTEPTYPE: FFScript::setComboData_step_type(); break;
39192 case SCDSTEPCHANGETO: FFScript::setComboData_step_change_to(); break;
39193 case SCDSTRIKEREMNANTS: FFScript::setComboData_strike_remnants(); break;
39194 case SCDSTRIKEREMNANTSTYPE: FFScript::setComboData_strike_remnants_type(); break;
39195 case SCDSTRIKECHANGE: FFScript::setComboData_strike_change(); break;
39196 case SCDSTRIKECHANGEITEM: FFScript::setComboData_strike_item(); break;
39197 case SCDTOUCHITEM: FFScript::setComboData_touch_item(); break;
39198 case SCDTOUCHSTAIRS: FFScript::setComboData_touch_stairs(); break;
39199 case SCDTRIGGERTYPE: FFScript::setComboData_trigger_type(); break;
39200 case SCDTRIGGERSENS: FFScript::setComboData_trigger_sensitive(); break;
39201 case SCDWARPTYPE: FFScript::setComboData_warp_type(); break;
39202 case SCDWARPSENS: FFScript::setComboData_warp_sensitive(); break;
39203 case SCDWARPDIRECT: FFScript::setComboData_warp_direct(); break;
39204 case SCDWARPLOCATION: FFScript::setComboData_warp_location(); break;
39205 case SCDWATER: FFScript::setComboData_water(); break;
39206 case SCDWHISTLE: FFScript::setComboData_whistle(); break;
39207 case SCDWINGAME: FFScript::setComboData_win_game(); break;
39208 case SCDBLOCKWEAPLVL: FFScript::setComboData_block_weapon_lvl(); break;
39209 case SCDTILE: FFScript::setComboData_tile(); break;
39210 case SCDFLIP: FFScript::setComboData_flip(); break;
39211 case SCDWALK: FFScript::setComboData_walk(); break;
39212 case SCDTYPE: FFScript::setComboData_type(); break;
39213 case SCDCSETS: FFScript::setComboData_csets(); break;
39214 case SCDFOO: break;
39215 case SCDFRAMES: FFScript::setComboData_frames(); break;
39216 case SCDSPEED: FFScript::setComboData_speed(); break;
39217 case SCDNEXTCOMBO: FFScript::setComboData_nextcombo(); break;
39218 case SCDNEXTCSET: FFScript::setComboData_nextcset(); break;
39219 case SCDFLAG: FFScript::setComboData_flag(); break;
39220 case SCDSKIPANIM: FFScript::setComboData_skipanim(); break;
39221 case SCDNEXTTIMER: FFScript::setComboData_nexttimer(); break;
39222 case SCDSKIPANIMY: FFScript::setComboData_skipanimy(); break;
39223 case SCDANIMFLAGS: FFScript::setComboData_animflags(); break;
39224 case SCDBLOCKWEAPON: FFScript::setComboData_block_weapon(ri->d[rEXP1]); break;
39225 case SCDEXPANSION: FFScript::setComboData_expansion(ri->d[rEXP1]); break;
39226 case SCDSTRIKEWEAPONS: FFScript::setComboData_strike_weapons(ri->d[rEXP1]); break;
39227
39228 //SpriteData
39229
39230 //case GETSPRITEDATASTRING:
39231 case GETSPRITEDATATILE: FFScript::getSpriteDataTile(); break;
39232 case GETSPRITEDATAMISC: FFScript::getSpriteDataCSets(); break;
39233 case GETSPRITEDATACGETS: FFScript::getSpriteDataCSets(); break;
39234 case GETSPRITEDATAFRAMES: FFScript::getSpriteDataFrames(); break;
39235 case GETSPRITEDATASPEED: FFScript::getSpriteDataSpeed(); break;
39236 case GETSPRITEDATATYPE: FFScript::getSpriteDataType(); break;
39237
39238 //case SETSPRITEDATASTRING:
39239 case SETSPRITEDATATILE: FFScript::setSpriteDataTile(); break;
39240 case SETSPRITEDATAMISC: FFScript::setSpriteDataMisc(); break;
39241 case SETSPRITEDATACSETS: FFScript::setSpriteDataCSets(); break;
39242 case SETSPRITEDATAFRAMES: FFScript::setSpriteDataFrames(); break;
39243 case SETSPRITEDATASPEED: FFScript::setSpriteDataSpeed(); break;
39244 case SETSPRITEDATATYPE: FFScript::setSpriteDataType(); break;
39245
39246 //Game over Screen
39247 case SETCONTINUESCREEN: FFScript::FFChangeSubscreenText(); break;
39248 case SETCONTINUESTRING: FFScript::FFSetSaveScreenSetting(); break;
39249
39250 //new npc functions for npc scripts
39251
39252 case NPCDEAD:
39253 FFCore.do_isdeadnpc();
39254 break;
39255
39256 case NPCCANSLIDE:
39257 FFCore.do_canslidenpc();
39258 break;
39259
39260 case NPCSLIDE:
39261 FFCore.do_slidenpc();
39262 break;
39263
39264 case NPCKICKBUCKET:
39265 {
39266 FFScript::deallocateAllScriptOwned(ScriptType::NPC, ri->guyref);
39267 if(type == ScriptType::NPC && ri->guyref == i)
39268 {
39269 FFCore.do_npc_delete();
39270 return RUNSCRIPT_SELFDELETE;
39271 }
39272 FFCore.do_npc_delete();
39273 break;
39274 }
39275 case LWPNDEL:
39276 {
39277 2 FFScript::deallocateAllScriptOwned(ScriptType::Lwpn, ri->lwpn);
39278
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(type == ScriptType::Lwpn && ri->lwpn == i)
39279 {
39280 2 FFCore.do_lweapon_delete();
39281 2 return RUNSCRIPT_SELFDELETE;
39282 }
39283 FFCore.do_lweapon_delete();
39284 break;
39285 }
39286 case EWPNDEL:
39287 {
39288 FFScript::deallocateAllScriptOwned(ScriptType::Ewpn, ri->ewpn);
39289 if(type == ScriptType::Ewpn && ri->ewpn == i)
39290 {
39291 FFCore.do_eweapon_delete();
39292 return RUNSCRIPT_SELFDELETE;
39293 }
39294 FFCore.do_eweapon_delete();
39295 break;
39296 }
39297 case ITEMDEL:
39298 {
39299 8 FFScript::deallocateAllScriptOwned(ScriptType::ItemSprite, ri->itemref);
39300
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(type == ScriptType::ItemSprite && ri->itemref == i)
39301 {
39302
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(FFCore.do_itemsprite_delete())
39303 8 return RUNSCRIPT_SELFDELETE;
39304 }
39305 else FFCore.do_itemsprite_delete();
39306 break;
39307 }
39308
39309 case NPCSTOPBGSFX:
39310 FFCore.do_npc_stopbgsfx();
39311 break;
39312
39313 case NPCATTACK:
39314 FFCore.do_npcattack();
39315 break;
39316
39317 case NPCNEWDIR:
39318 FFCore.do_npc_newdir();
39319 break;
39320
39321 case NPCCONSTWALK:
39322 FFCore.do_npc_constwalk();
39323 break;
39324
39325
39326
39327 case NPCVARWALK:
39328 FFCore.do_npc_varwalk();
39329 break;
39330
39331 case NPCVARWALK8:
39332 FFCore.do_npc_varwalk8();
39333 break;
39334
39335 case NPCCONSTWALK8:
39336 FFCore.do_npc_constwalk8();
39337 break;
39338
39339 case NPCHALTWALK:
39340 FFCore.do_npc_haltwalk();
39341 break;
39342
39343 case NPCHALTWALK8:
39344 FFCore.do_npc_haltwalk8();
39345 break;
39346
39347 case NPCFLOATWALK:
39348 FFCore.do_npc_floatwalk();
39349 break;
39350
39351 case NPCFIREBREATH:
39352 FFCore.do_npc_breathefire();
39353 break;
39354
39355 case NPCNEWDIR8:
39356 FFCore.do_npc_newdir8();
39357 break;
39358
39359 case NPCLINKINRANGE:
39360 FFCore.do_npc_hero_in_range(false);
39361 break;
39362
39363 case NPCCANMOVE:
39364 FFCore.do_npc_canmove(false);
39365 break;
39366
39367 case NPCHITWITH:
39368 FFCore.do_npc_simulate_hit(false);
39369 break;
39370
39371 case NPCKNOCKBACK:
39372 FFCore.do_npc_knockback(false);
39373 break;
39374
39375 case NPCGETINITDLABEL:
39376 FFCore.get_npcdata_initd_label(false);
39377 break;
39378
39379 case NPCADD:
39380 FFCore.do_npc_add(false);
39381 break;
39382
39383 case NPCMOVEPAUSED:
39384 {
39385 ri->d[rEXP1] = 0;
39386 if(GuyH::loadNPC(ri->guyref, "npc->MovePaused()") == SH::_NoError)
39387 {
39388 ri->d[rEXP1] = GuyH::getNPC()->is_move_paused() ? 10000 : 0;
39389 }
39390 break;
39391 }
39392 case NPCMOVE:
39393 {
39394 int32_t dir = ri->d[rINDEX] / 10000;
39395 zfix px = zslongToFix(ri->d[rEXP2]);
39396 int32_t special = ri->d[rEXP1] / 10000;
39397 ri->d[rEXP1] = 0;
39398 if(GuyH::loadNPC(ri->guyref, "npc->Move()") == SH::_NoError)
39399 {
39400 ri->d[rEXP1] = GuyH::getNPC()->moveDir(dir, px, special) ? 10000 : 0;
39401 }
39402 break;
39403 }
39404 case NPCMOVEANGLE:
39405 {
39406 zfix degrees = zslongToFix(ri->d[rINDEX]);
39407 zfix px = zslongToFix(ri->d[rEXP2]);
39408 int32_t special = ri->d[rEXP1] / 10000;
39409 ri->d[rEXP1] = 0;
39410 if(GuyH::loadNPC(ri->guyref, "npc->MoveAtAngle()") == SH::_NoError)
39411 {
39412 ri->d[rEXP1] = GuyH::getNPC()->moveAtAngle(degrees, px, special) ? 10000 : 0;
39413 }
39414 break;
39415 }
39416 case NPCMOVEXY:
39417 {
39418 zfix dx = zslongToFix(ri->d[rINDEX]);
39419 zfix dy = zslongToFix(ri->d[rEXP2]);
39420 int32_t special = ri->d[rEXP1] / 10000;
39421 ri->d[rEXP1] = 0;
39422 if(GuyH::loadNPC(ri->guyref, "npc->MoveXY()") == SH::_NoError)
39423 {
39424 ri->d[rEXP1] = GuyH::getNPC()->movexy(dx, dy, special) ? 10000 : 00;
39425 }
39426 break;
39427 }
39428 case NPCCANMOVEDIR:
39429 {
39430 int32_t dir = ri->d[rINDEX] / 10000;
39431 zfix px = zslongToFix(ri->d[rEXP2]);
39432 int32_t special = ri->d[rEXP1] / 10000;
39433 ri->d[rEXP1] = 0;
39434 if(GuyH::loadNPC(ri->guyref, "npc->CanMove()") == SH::_NoError)
39435 {
39436 ri->d[rEXP1] = GuyH::getNPC()->can_moveDir(dir, px, special) ? 10000 : 0;
39437 }
39438 break;
39439 }
39440 case NPCCANMOVEANGLE:
39441 {
39442 zfix degrees = zslongToFix(ri->d[rINDEX]);
39443 zfix px = zslongToFix(ri->d[rEXP2]);
39444 int32_t special = ri->d[rEXP1] / 10000;
39445 ri->d[rEXP1] = 0;
39446 if(GuyH::loadNPC(ri->guyref, "npc->CanMoveAtAngle()") == SH::_NoError)
39447 {
39448 ri->d[rEXP1] = GuyH::getNPC()->can_moveAtAngle(degrees, px, special) ? 10000 : 0;
39449 }
39450 break;
39451 }
39452 case NPCCANMOVEXY:
39453 {
39454 zfix dx = zslongToFix(ri->d[rINDEX]);
39455 zfix dy = zslongToFix(ri->d[rEXP2]);
39456 int32_t special = ri->d[rEXP1] / 10000;
39457 ri->d[rEXP1] = 0;
39458 if(GuyH::loadNPC(ri->guyref, "npc->CanMoveXY()") == SH::_NoError)
39459 {
39460 ri->d[rEXP1] = GuyH::getNPC()->can_movexy(dx, dy, special) ? 10000 : 0;
39461 }
39462 break;
39463 }
39464 case NPCCANPLACE:
39465 {
39466 ri->guyref = SH::read_stack(ri->sp + 6);
39467 ri->d[rEXP1] = 0;
39468 if(GuyH::loadNPC(ri->guyref, "npc->CanPlace()") == SH::_NoError)
39469 {
39470 zfix nx = zslongToFix(SH::read_stack(ri->sp + 5));
39471 zfix ny = zslongToFix(SH::read_stack(ri->sp + 4));
39472 int special = SH::read_stack(ri->sp + 3) / 10000;
39473 bool kb = SH::read_stack(ri->sp + 2)!=0;
39474 int nw = SH::read_stack(ri->sp + 1) / 10000;
39475 int nh = SH::read_stack(ri->sp + 0) / 10000;
39476 ri->d[rEXP1] = GuyH::getNPC()->scr_canplace(nx, ny, special, kb, nw, nh) ? 10000 : 0;
39477 }
39478 break;
39479 }
39480
39481 case PLAYENHMUSICEX:
39482 // DEPRECATED
39483 do_enh_music(false);
39484 break;
39485
39486 case GETENHMUSICPOS:
39487 FFCore.do_get_music_position();
39488 break;
39489
39490 case SETENHMUSICPOS:
39491 FFCore.do_set_music_position(false);
39492 break;
39493
39494 case SETENHMUSICSPEED:
39495 FFCore.do_set_music_speed(false);
39496 break;
39497
39498 case GETENHMUSICLEN:
39499 FFCore.do_get_music_length();
39500 break;
39501
39502 case SETENHMUSICLOOP:
39503 FFCore.do_set_music_loop();
39504 break;
39505
39506 case ENHCROSSFADE:
39507 do_enh_music_crossfade();
39508 break;
39509
39510 case DIREXISTS:
39511 FFCore.do_checkdir(true);
39512 break;
39513
39514 case FILEEXISTS:
39515 FFCore.do_checkdir(false);
39516 break;
39517
39518 case FILESYSREMOVE:
39519 FFCore.do_fs_remove();
39520 break;
39521
39522 case TOBYTE:
39523 do_tobyte();
39524 break;
39525 case TOWORD:
39526 do_toword();
39527 break;
39528 case TOSHORT: do_toshort(); break;
39529 case TOSIGNEDBYTE: do_tosignedbyte(); break;
39530 case TOINTEGER: do_tointeger(); break;
39531 case CEILING: do_ceiling(); break;
39532 case FLOOR: do_floor(); break;
39533
39534 case FILECLOSE:
39535 {
39536 FFCore.do_fclose();
39537 break;
39538 }
39539 case FILEFREE:
39540 {
39541 1 FFCore.do_deallocate_file();
39542 1 break;
39543 }
39544 case FILEOWN:
39545 {
39546 1 user_file* f = checkFile(ri->fileref, "Free()", false);
39547
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(f) f->own(type, i);
39548 1 break;
39549 }
39550 case FILEISALLOCATED:
39551 {
39552 FFCore.do_file_isallocated();
39553 break;
39554 }
39555 case FILEISVALID:
39556 {
39557 FFCore.do_file_isvalid();
39558 break;
39559 }
39560 case FILEALLOCATE:
39561 {
39562 FFCore.do_allocate_file();
39563 break;
39564 }
39565 case FILEFLUSH:
39566 {
39567 1 FFCore.do_fflush();
39568 1 break;
39569 }
39570 case FILEREMOVE:
39571 {
39572 FFCore.do_fremove();
39573 break;
39574 }
39575 case FILEGETCHAR:
39576 {
39577 FFCore.do_file_getchar();
39578 break;
39579 }
39580 case FILEREWIND:
39581 {
39582 FFCore.do_file_rewind();
39583 break;
39584 }
39585 case FILECLEARERR:
39586 {
39587 FFCore.do_file_clearerr();
39588 break;
39589 }
39590
39591 case FILEOPEN:
39592 {
39593 1 FFCore.do_fopen(false, "rb+");
39594 1 break;
39595 }
39596 case FILECREATE:
39597 {
39598 1 FFCore.do_fopen(false, "wb+");
39599 1 break;
39600 }
39601 case FILEOPENMODE:
39602 {
39603 int32_t arrayptr = get_register(sarg2) / 10000;
39604 string mode;
39605 ArrayH::getString(arrayptr, mode, 16);
39606 FFCore.do_fopen(false, mode.c_str());
39607 break;
39608 }
39609 case FILEREADSTR:
39610 {
39611 FFCore.do_file_readstring();
39612 break;
39613 }
39614 case FILEWRITESTR:
39615 {
39616 279 FFCore.do_file_writestring();
39617 279 break;
39618 }
39619 case FILEPUTCHAR:
39620 {
39621 FFCore.do_file_putchar();
39622 break;
39623 }
39624 case FILEUNGETCHAR:
39625 {
39626 FFCore.do_file_ungetchar();
39627 break;
39628 }
39629
39630 case FILEREADCHARS:
39631 {
39632 FFCore.do_file_readchars();
39633 break;
39634 }
39635 case FILEREADBYTES:
39636 {
39637 FFCore.do_file_readbytes();
39638 break;
39639 }
39640 case FILEREADINTS:
39641 {
39642 FFCore.do_file_readints();
39643 break;
39644 }
39645 case FILEWRITECHARS:
39646 {
39647 FFCore.do_file_writechars();
39648 break;
39649 }
39650 case FILEWRITEBYTES:
39651 {
39652 FFCore.do_file_writebytes();
39653 break;
39654 }
39655 case FILEWRITEINTS:
39656 {
39657 FFCore.do_file_writeints();
39658 break;
39659 }
39660 case FILESEEK:
39661 {
39662 FFCore.do_file_seek();
39663 break;
39664 }
39665 case FILEGETERROR:
39666 {
39667 FFCore.do_file_geterr();
39668 break;
39669 }
39670 //Directory
39671 case DIRECTORYGET:
39672 {
39673 FFCore.do_directory_get();
39674 break;
39675 }
39676 case DIRECTORYRELOAD:
39677 {
39678 FFCore.do_directory_reload();
39679 break;
39680 }
39681 case DIRECTORYFREE:
39682 {
39683 FFCore.do_directory_free();
39684 break;
39685 }
39686 case DIRECTORYOWN:
39687 {
39688 if(user_dir* dr = checkDir(ri->directoryref, "Own()"))
39689 {
39690 dr->own(type, i);
39691 }
39692 break;
39693 }
39694 //Stack
39695 case STACKFREE:
39696 {
39697 if(user_stack* st = checkStack(ri->stackref, "Free()", true))
39698 {
39699 st->clear();
39700 }
39701 break;
39702 }
39703 case STACKOWN:
39704 {
39705 if(user_stack* st = checkStack(ri->stackref, "Own()"))
39706 {
39707 st->own(type, i);
39708 }
39709 break;
39710 }
39711 case STACKCLEAR:
39712 {
39713 if(user_stack* st = checkStack(ri->stackref, "Clear()"))
39714 {
39715 st->clearStack();
39716 }
39717 break;
39718 }
39719 case STACKGET:
39720 {
39721 if(user_stack* st = checkStack(ri->stackref, "Get()", true))
39722 {
39723 int32_t indx = get_register(sarg1); //NOT /10000
39724 set_register(sarg1, st->get(indx)); //NOT *10000
39725 }
39726 else set_register(sarg1, 0L);
39727 break;
39728 }
39729 case STACKSET:
39730 {
39731 if(user_stack* st = checkStack(ri->stackref, "Set()", true))
39732 {
39733 int32_t indx = get_register(sarg1); //NOT /10000
39734 int32_t val = get_register(sarg2); //NOT /10000
39735 st->set(indx, val); //NOT *10000
39736 }
39737 break;
39738 }
39739 case STACKPOPBACK:
39740 {
39741 if(user_stack* st = checkStack(ri->stackref, "PopBack()", true))
39742 {
39743 set_register(sarg1, st->pop_back()); //NOT *10000
39744 }
39745 else set_register(sarg1, 0L);
39746 break;
39747 }
39748 case STACKPOPFRONT:
39749 {
39750 if(user_stack* st = checkStack(ri->stackref, "PopFront()", true))
39751 {
39752 set_register(sarg1, st->pop_front()); //NOT *10000
39753 }
39754 else set_register(sarg1, 0L);
39755 break;
39756 }
39757 case STACKPEEKBACK:
39758 {
39759 if(user_stack* st = checkStack(ri->stackref, "PeekBack()", true))
39760 {
39761 set_register(sarg1, st->peek_back()); //NOT *10000
39762 }
39763 else set_register(sarg1, 0L);
39764 break;
39765 }
39766 case STACKPEEKFRONT:
39767 {
39768 if(user_stack* st = checkStack(ri->stackref, "PeekFront()", true))
39769 {
39770 set_register(sarg1, st->peek_front()); //NOT *10000
39771 }
39772 else set_register(sarg1, 0L);
39773 break;
39774 }
39775 case STACKPUSHBACK:
39776 {
39777 if(user_stack* st = checkStack(ri->stackref, "PushBack()", true))
39778 {
39779 int32_t val = get_register(sarg1); //NOT /10000
39780 st->push_back(val);
39781 }
39782 break;
39783 }
39784 case STACKPUSHFRONT:
39785 {
39786 if(user_stack* st = checkStack(ri->stackref, "PushFront()", true))
39787 {
39788 int32_t val = get_register(sarg1); //NOT /10000
39789 st->push_front(val);
39790 }
39791 break;
39792 }
39793
39794 //Module
39795 case MODULEGETIC:
39796 {
39797
39798 int32_t buf_pointer = SH::get_arg(sarg1, false) / 10000;
39799 int32_t element = SH::get_arg(sarg2, false) / 10000;
39800
39801 if ( ((unsigned)element) > 511 )
39802 {
39803 Z_scripterrlog("Illegal itemclass supplied to ZInfo->GetItemClass().\nLegal values are 1 to 511.\n");
39804 }
39805 else
39806 {
39807 char buffer[256] = {0};
39808 strcpy(buffer,ZI.getItemClassName(element));
39809 buffer[255] = '\0';
39810 if(ArrayH::setArray(buf_pointer, buffer) == SH::_Overflow)
39811 {
39812 Z_scripterrlog("Dest string supplied to 'Module->GetItemClass()' is not large enough\n");
39813 }
39814 }
39815
39816 break;
39817 }
39818
39819 //{ Randgen Stuff
39820 case RNGRAND1:
39821 if(user_rng* r = checkRNG(ri->rngref, "Rand()"))
39822 {
39823 ri->d[rEXP1] = r->rand(214748, -214748)*10000L;
39824 }
39825 else ri->d[rEXP1] = -10000L;
39826 break;
39827 case RNGRAND2:
39828
1/2
✓ Branch 0 taken 1338 times.
✗ Branch 1 not taken.
1338 if(user_rng* r = checkRNG(ri->rngref, "Rand(int32_t)"))
39829 {
39830 1338 set_register(sarg1,r->rand(get_register(sarg1)/10000L)*10000L);
39831 1338 }
39832 else set_register(sarg1,-10000L);
39833 1338 break;
39834 case RNGRAND3:
39835
1/2
✓ Branch 0 taken 301905 times.
✗ Branch 1 not taken.
301905 if(user_rng* r = checkRNG(ri->rngref, "Rand(int32_t,int32_t)"))
39836 {
39837 301905 set_register(sarg1,r->rand(get_register(sarg1)/10000L, get_register(sarg2)/10000L)* 10000L);
39838 301905 }
39839 else set_register(sarg1,-10000L);
39840 301905 break;
39841 case RNGLRAND1:
39842 if(user_rng* r = checkRNG(ri->rngref, "LRand()"))
39843 {
39844 ri->d[rEXP1] = r->rand();
39845 }
39846 else ri->d[rEXP1] = -10000L;
39847 break;
39848 case RNGLRAND2:
39849 if(user_rng* r = checkRNG(ri->rngref, "LRand(int32_t)"))
39850 {
39851 ri->d[rEXP1] = r->rand(get_register(sarg1));
39852 }
39853 else ri->d[rEXP1] = -10000L;
39854 break;
39855 case RNGLRAND3:
39856 if(user_rng* r = checkRNG(ri->rngref, "LRand(int32_t,int32_t)"))
39857 {
39858 ri->d[rEXP1] = r->rand(get_register(sarg1), get_register(sarg2));
39859 }
39860 else ri->d[rEXP1] = -10000L;
39861 break;
39862 case RNGSEED:
39863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 if(user_rng* r = checkRNG(ri->rngref, "SRand(int32_t)"))
39864 {
39865 73 r->srand(get_register(sarg1));
39866 73 }
39867 73 break;
39868 case RNGRSEED:
39869 if(user_rng* r = checkRNG(ri->rngref, "SRand()"))
39870 {
39871 ri->d[rEXP1] = r->srand();
39872 }
39873 else ri->d[rEXP1] = -10000;
39874 break;
39875 case RNGFREE:
39876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(user_rng* r = checkRNG(ri->rngref, "Free()", true))
39877 {
39878 6 r->clear();
39879 6 }
39880 6 break;
39881 case RNGOWN:
39882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(user_rng* r = checkRNG(ri->rngref, "Own()", false))
39883 {
39884 8 r->own(type, i);
39885 8 }
39886 8 break;
39887 //}
39888 case LOADGENERICDATA:
39889 68 FFCore.do_loadgenericdata(false); break;
39890 case RUNGENFRZSCR:
39891 {
39892 10 bool r = FFCore.runGenericFrozenEngine(word(ri->genericdataref));
39893 10 set_register(sarg1, r ? 10000L : 0L);
39894 10 break;
39895 }
39896
39897 ///----------------------------------------------------------------------------------------------------//
39898
39899 case SUBDATA_GET_NAME:
39900 {
39901 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "GetName"))
39902 {
39903 auto aptr = get_register(sarg1) / 10000;
39904 if(ArrayH::setArray(aptr, sub->name, true) == SH::_Overflow)
39905 Z_scripterrlog("Array supplied to 'subscreendata->GetName()' not large enough,"
39906 " and couldn't be resized!\n");
39907 }
39908 break;
39909 }
39910 case SUBDATA_SET_NAME:
39911 {
39912 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SetName"))
39913 {
39914 auto aptr = get_register(sarg1) / 10000;
39915 ArrayH::getString(aptr, sub->name);
39916 }
39917 break;
39918 }
39919 case SUBDATA_SWAP_PAGES:
39920 {
39921 ri->subdataref = SH::read_stack(ri->sp+2);
39922 if(ZCSubscreen* sub = checkSubData(ri->subdataref, "SwapPages"))
39923 {
39924 int p1 = SH::read_stack(ri->sp+1) / 10000;
39925 int p2 = SH::read_stack(ri->sp+0) / 10000;
39926 if(unsigned(p1) >= sub->pages.size())
39927 Z_scripterrlog("Invalid page index '%d' passed to subscreendata->SwapPages()\n", p1);
39928 else if(unsigned(p2) >= sub->pages.size())
39929 Z_scripterrlog("Invalid page index '%d' passed to subscreendata->SwapPages()\n", p2);
39930 else sub->swap_pages(p1,p2);
39931 }
39932 break;
39933 }
39934 case SUBPAGE_SWAP_WIDG:
39935 {
39936 ri->subpageref = SH::read_stack(ri->sp+2);
39937 if(SubscrPage* pg = checkSubPage(ri->subpageref, "SwapWidgets"))
39938 {
39939 int p1 = SH::read_stack(ri->sp+1) / 10000;
39940 int p2 = SH::read_stack(ri->sp+0) / 10000;
39941 if(unsigned(p1) >= pg->size())
39942 Z_scripterrlog("Invalid page index '%d' passed to subscreenpage->SwapWidgets()\n", p1);
39943 else if(unsigned(p2) >= pg->size())
39944 Z_scripterrlog("Invalid page index '%d' passed to subscreenpage->SwapWidgets()\n", p2);
39945 else pg->swap_widg(p1,p2);
39946 }
39947 break;
39948 }
39949 case SUBPAGE_FIND_WIDGET:
39950 {
39951 ri->d[rEXP1] = 0;
39952 ri->subpageref = SH::read_stack(ri->sp+1);
39953 if(SubscrPage* pg = checkSubPage(ri->subpageref, "FindWidget", sstACTIVE))
39954 {
39955 int cursorpos = SH::read_stack(ri->sp+0) / 10000;
39956 if(auto* widg = pg->get_widg_pos(cursorpos,false))
39957 {
39958 auto q = pg->widget_index(widg);
39959 if(q > -1)
39960 {
39961 auto [sub,ty,pgid,_ind] = from_subref(ri->subpageref);
39962 ri->d[rEXP1] = get_subref(sub,ty,pgid,q);
39963 }
39964 }
39965 }
39966 break;
39967 }
39968 case SUBPAGE_FIND_WIDGET_BY_LABEL:
39969 {
39970 ri->d[rEXP1] = 0;
39971 ri->subpageref = SH::read_stack(ri->sp+1);
39972 if(SubscrPage* pg = checkSubPage(ri->subpageref, "GetWidget"))
39973 {
39974 int aptr = SH::read_stack(ri->sp+0) / 10000;
39975 std::string lbl;
39976 ArrayH::getString(aptr, lbl);
39977 if(lbl.size())
39978 {
39979 auto q = pg->find_label_index(lbl);
39980 if(q > -1)
39981 {
39982 auto [sub,ty,pgid,_ind] = from_subref(ri->subpageref);
39983 ri->d[rEXP1] = get_subref(sub,ty,pgid,q);
39984 }
39985 }
39986 }
39987 break;
39988 }
39989 case SUBPAGE_MOVE_SEL:
39990 {
39991 #define SUBSEL_FLAG_NO_NONEQUIP 0x01
39992 #define SUBSEL_FLAG_NEED_ITEM 0x02
39993 ri->subpageref = SH::read_stack(ri->sp+3);
39994 if(SubscrPage* pg = checkSubPage(ri->subpageref, "SelectorMove"))
39995 {
39996 int flags = SH::read_stack(ri->sp+0) / 10000;
39997 int dir = SH::read_stack(ri->sp+1) / 10000;
39998 int pos = SH::read_stack(ri->sp+2) / 10000;
39999 switch(dir)
40000 {
40001 case up:
40002 dir = SEL_UP;
40003 break;
40004 case down:
40005 dir = SEL_DOWN;
40006 break;
40007 case left:
40008 dir = SEL_LEFT;
40009 break;
40010 case right: default:
40011 dir = SEL_RIGHT;
40012 break;
40013 }
40014
40015 auto newpos = pg->movepos_legacy(dir, (pos<<8)|pg->getIndex(),
40016 255, 255, 255, flags&SUBSEL_FLAG_NO_NONEQUIP,
40017 flags&SUBSEL_FLAG_NEED_ITEM, true) >> 8;
40018 ri->d[rEXP1] = 10000*newpos;
40019 }
40020 break;
40021 }
40022 case SUBPAGE_NEW_WIDG:
40023 {
40024 ri->subpageref = SH::read_stack(ri->sp+1);
40025 if(SubscrPage* pg = checkSubPage(ri->subpageref, "CreateWidget"))
40026 {
40027 if(pg->size() == 0x2000)
40028 break; //Page is full!
40029 int ty = SH::read_stack(ri->sp+0) / 10000;
40030 if(auto* widg = SubscrWidget::newType(ty))
40031 {
40032 widg->posflags = sspUP | sspDOWN | sspSCROLLING;
40033 widg->w = 1;
40034 widg->h = 1;
40035 pg->push_back(widg);
40036 auto [sub,ty,pgid,_ind] = from_subref(ri->subpageref);
40037 ri->d[rEXP1] = get_subref(sub,ty,pgid,pg->size()-1);
40038 }
40039 else Z_scripterrlog("Invalid type %d passed to subscreenpage->CreateWidget()\n",ty);
40040 }
40041 break;
40042 }
40043 case SUBPAGE_DELETE:
40044 {
40045 if(SubscrPage* pg = checkSubPage(ri->subpageref, "Delete"))
40046 {
40047 auto [sub,_ty] = load_subdata(ri->subpageref);
40048 sub->delete_page(pg->getIndex());
40049 }
40050 break;
40051 }
40052 case SUBWIDG_GET_SELTEXT_OVERRIDE:
40053 {
40054 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GetSelTextOverride"))
40055 {
40056 auto aptr = get_register(sarg1) / 10000;
40057 if(ArrayH::setArray(aptr, widg->override_text, true) == SH::_Overflow)
40058 Z_scripterrlog("Array supplied to 'subscreenwidget->GetSelTextOverride()' not large enough,"
40059 " and couldn't be resized!\n");
40060 }
40061 break;
40062 }
40063 case SUBWIDG_SET_SELTEXT_OVERRIDE:
40064 {
40065 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SetSelTextOverride"))
40066 {
40067 auto aptr = get_register(sarg1) / 10000;
40068 ArrayH::getString(aptr, widg->override_text);
40069 }
40070 break;
40071 }
40072 case SUBWIDG_GET_LABEL:
40073 {
40074 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GetLabel"))
40075 {
40076 auto aptr = get_register(sarg1) / 10000;
40077 if(ArrayH::setArray(aptr, widg->label, true) == SH::_Overflow)
40078 Z_scripterrlog("Array supplied to 'subscreenwidget->GetLabel()' not large enough,"
40079 " and couldn't be resized!\n");
40080 }
40081 break;
40082 }
40083 case SUBWIDG_SET_LABEL:
40084 {
40085 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SetLabel"))
40086 {
40087 auto aptr = get_register(sarg1) / 10000;
40088 ArrayH::getString(aptr, widg->label);
40089 }
40090 break;
40091 }
40092 case SUBWIDG_TY_GETTEXT:
40093 {
40094 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "GetText"))
40095 {
40096 std::string const* str = nullptr;
40097 byte ty = widg->getType();
40098 switch(ty)
40099 {
40100 case widgTEXT:
40101 str = &((SW_Text*)widg)->text;
40102 break;
40103 case widgTEXTBOX:
40104 str = &((SW_TextBox*)widg)->text;
40105 break;
40106 default:
40107 bad_subwidg_type("GetText()", true, ty);
40108 break;
40109 }
40110 if(str)
40111 {
40112 auto aptr = get_register(sarg1) / 10000;
40113 if(ArrayH::setArray(aptr, *str, true) == SH::_Overflow)
40114 Z_scripterrlog("Array supplied to 'subscreenwidget->GetText()' not large enough,"
40115 " and couldn't be resized!\n");
40116 }
40117 }
40118 break;
40119 }
40120 case SUBWIDG_TY_SETTEXT:
40121 {
40122 if(SubscrWidget* widg = checkSubWidg(ri->subwidgref, "SetText"))
40123 {
40124 std::string* str = nullptr;
40125 byte ty = widg->getType();
40126 switch(ty)
40127 {
40128 case widgTEXT:
40129 str = &((SW_Text*)widg)->text;
40130 break;
40131 case widgTEXTBOX:
40132 str = &((SW_TextBox*)widg)->text;
40133 break;
40134 default:
40135 bad_subwidg_type("SetText()", true, ty);
40136 break;
40137 }
40138 if(str)
40139 {
40140 auto aptr = get_register(sarg1) / 10000;
40141 ArrayH::getString(aptr, *str);
40142 }
40143 }
40144 break;
40145 }
40146 default:
40147 {
40148 Z_scripterrlog("Invalid ZASM command %lu reached; terminating\n", scommand);
40149 hit_invalid_zasm = true;
40150 scommand = 0xFFFF;
40151 break;
40152 }
40153 }
40154
1/2
✓ Branch 0 taken 708311077 times.
✗ Branch 1 not taken.
708311077 if(earlyretval == RUNSCRIPT_SELFDELETE)
40155 {
40156 earlyretval = -1;
40157 return RUNSCRIPT_SELFDELETE;
40158 }
40159
1/2
✓ Branch 0 taken 708311077 times.
✗ Branch 1 not taken.
708311077 if (ri->sp >= MAX_SCRIPT_REGISTERS)
40160 {
40161 if (script_funcrun)
40162 return RUNSCRIPT_OK;
40163 Z_scripterrlog("Stack over/underflow caused by command %d!\n", scommand);
40164 }
40165
1/2
✓ Branch 0 taken 708311077 times.
✗ Branch 1 not taken.
708311077 if(hit_invalid_zasm) break;
40166
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 708311077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
708311077 if(script_funcrun && (ri->pc == MAX_PC || scommand == RETURN))
40167 return RUNSCRIPT_OK;
40168
40169 #ifdef _SCRIPT_COUNTER
40170 end_time = std::chrono::steady_clock::now();
40171 script_timer[scommand] += std::chrono::duration_cast<std::chrono::nanoseconds>(end_time - start_time).count();
40172 script_execount[scommand] += 1;
40173 #endif
40174
40175
2/2
✓ Branch 0 taken 708249114 times.
✓ Branch 1 taken 61963 times.
708311077 if (type == ScriptType::Combo)
40176 {
40177
1/2
✓ Branch 0 taken 61963 times.
✗ Branch 1 not taken.
61963 if(combopos_modified == i)
40178 {
40179 //Combo changed! Abort script!
40180 return RUNSCRIPT_OK;
40181 }
40182 61963 }
40183
1/2
✓ Branch 0 taken 708311077 times.
✗ Branch 1 not taken.
708311077 if(increment) ri->pc++;
40184 else increment = true;
40185
1/2
✓ Branch 0 taken 708311077 times.
✗ Branch 1 not taken.
708311077 if ( ri->pc == MAX_PC ) //rolled over from overflow?
40186 {
40187 Z_scripterrlog("Script PC overflow! Too many ZASM lines?\n");
40188 ri->pc = 0;
40189 scommand = 0xFFFF;
40190 }
40191
40192
1/2
✓ Branch 0 taken 708311077 times.
✗ Branch 1 not taken.
708311077 if(earlyretval > -1) //Should this be below the 'commands_run += 1'? Unsure. -Em
40193 {
40194 auto v = earlyretval;
40195 earlyretval = -1;
40196 return earlyretval;
40197 }
40198
40199 // If running a JIT compiled script, we're only here to do a few commands.
40200 708311077 commands_run += 1;
40201
3/4
✓ Branch 0 taken 708311077 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3093977 times.
✓ Branch 3 taken 705217100 times.
708311077 if (is_jitted && commands_run == jitted_uncompiled_command_count) break;
40202 }
40203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714815347 times.
714815347 if(script_funcrun) return RUNSCRIPT_OK;
40204
40205
2/2
✓ Branch 0 taken 714815336 times.
✓ Branch 1 taken 11 times.
714815347 if(!scriptCanSave)
40206 11 scriptCanSave=true;
40207
40208
2/2
✓ Branch 0 taken 712949773 times.
✓ Branch 1 taken 1865574 times.
714815347 if(scommand == WAITDRAW)
40209 {
40210
3/9
✓ Branch 0 taken 1852906 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 188 times.
✓ Branch 6 taken 12480 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
1865574 switch(type)
40211 {
40212 case ScriptType::Global:
40213 case ScriptType::Player:
40214 case ScriptType::DMap:
40215 case ScriptType::OnMap:
40216 case ScriptType::ScriptedPassiveSubscreen:
40217 case ScriptType::ScriptedActiveSubscreen:
40218 case ScriptType::Screen:
40219 case ScriptType::Combo:
40220 1852906 FFCore.waitdraw(type, i) = true;
40221 1852906 break;
40222
40223 case ScriptType::Item:
40224 {
40225 if (!get_qr(qr_NOITEMWAITDRAW))
40226 {
40227 FFCore.waitdraw(ScriptType::Item, i) = true;
40228 }
40229 break;
40230 }
40231
40232 case ScriptType::NPC:
40233 {
40234 //enemy *wp = (enemy*)guys.spr(i);
40235 //wp->waitdraw = 1;
40236 guys.spr(GuyH::getNPCIndex(i))->waitdraw = 1;
40237 break;
40238 }
40239 case ScriptType::Lwpn:
40240 {
40241 188 Lwpns.spr(LwpnH::getLWeaponIndex(i))->waitdraw = 1;
40242 188 break;
40243 }
40244
40245 case ScriptType::Ewpn:
40246 {
40247 12480 Ewpns.spr(EwpnH::getEWeaponIndex(i))->waitdraw = 1;
40248 12480 break;
40249 }
40250 case ScriptType::ItemSprite:
40251 {
40252 items.spr(ItemH::getItemIndex(i))->waitdraw = 1;
40253 break;
40254 }
40255
40256 case ScriptType::FFC:
40257 {
40258 if ( !(get_qr(qr_NOFFCWAITDRAW)) )
40259 {
40260 FFCore.waitdraw(ScriptType::FFC, i) = true;
40261 }
40262 else
40263 {
40264 Z_scripterrlog("Waitdraw cannot be used in script type: %s\n", "ffc, with Script Rule 'No FFC Waitdraw() enabled!");
40265 }
40266 break;
40267 }
40268
40269 case ScriptType::Generic:
40270 case ScriptType::GenericFrozen:
40271 case ScriptType::EngineSubscreen:
40272 //No Waitdraw
40273 break;
40274
40275 default:
40276 Z_scripterrlog("Waitdraw cannot be used in script type: %s\n", ScriptTypeToString(type));
40277 break;
40278 }
40279 1865574 }
40280
40281
2/2
✓ Branch 0 taken 70477 times.
✓ Branch 1 taken 714744870 times.
714815347 if(scommand == 0xFFFF) //Quit/command list end reached/bad command
40282 {
40283
8/11
✓ Branch 0 taken 1260 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6683 times.
✓ Branch 3 taken 18 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
✓ Branch 6 taken 1009 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60621 times.
✓ Branch 9 taken 836 times.
✓ Branch 10 taken 40 times.
70477 switch(type)
40284 {
40285 case ScriptType::FFC:
40286 {
40287 6683 tmpscr->ffcs[i].script = 0;
40288 6683 auto& data = get_script_engine_data(type, i);
40289 6683 data.doscript = false;
40290 }
40291 6683 break;
40292
40293 case ScriptType::Screen:
40294 18 tmpscr->script = 0;
40295 case ScriptType::Global:
40296 case ScriptType::Player:
40297 case ScriptType::DMap:
40298 case ScriptType::OnMap:
40299 case ScriptType::ScriptedActiveSubscreen:
40300 case ScriptType::ScriptedPassiveSubscreen:
40301 case ScriptType::EngineSubscreen:
40302 case ScriptType::Combo:
40303 {
40304 1278 auto& data = get_script_engine_data(type, i);
40305 1278 data.doscript = false;
40306 }
40307 1278 break;
40308
40309 case ScriptType::Generic:
40310 user_scripts[script].quit();
40311 break;
40312
40313 case ScriptType::GenericFrozen:
40314 10 gen_active_doscript = 0;
40315 10 break;
40316
40317 case ScriptType::Item:
40318 {
40319
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
1009 bool collect = ( ( i < 1 ) || (i == COLLECT_SCRIPT_ITEM_ZERO) );
40320
3/4
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
✓ Branch 2 taken 194 times.
✗ Branch 3 not taken.
1009 int new_i = ( collect ) ? (( i != COLLECT_SCRIPT_ITEM_ZERO ) ? (i * -1) : 0) : i;
40321 1009 auto& data = get_script_engine_data(ScriptType::Item, i);
40322
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
1009 if ( !collect )
40323 {
40324
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 815 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
815 if ( (itemsbuf[i].flags&ITEM_PASSIVESCRIPT) && game->item[i] ) itemsbuf[i].script = 0; //Quit perpetual scripts, too.
40325 815 data.doscript = 0;
40326 815 data.ref.Clear();
40327 815 }
40328 else
40329 {
40330 194 data.doscript = 0;
40331 194 data.ref.Clear();
40332 }
40333 1009 data.initialized = false;
40334 1009 break;
40335 }
40336 case ScriptType::NPC:
40337 {
40338 guys.spr(GuyH::getNPCIndex(i))->doscript = 0;
40339 guys.spr(GuyH::getNPCIndex(i))->weaponscript = 0;
40340 guys.spr(GuyH::getNPCIndex(i))->initialised = 0;
40341 break;
40342 }
40343 case ScriptType::Lwpn:
40344 {
40345 60621 Lwpns.spr(LwpnH::getLWeaponIndex(i))->doscript = 0;
40346 60621 Lwpns.spr(LwpnH::getLWeaponIndex(i))->weaponscript = 0;
40347 60621 Lwpns.spr(LwpnH::getLWeaponIndex(i))->initialised = 0;
40348 60621 break;
40349 }
40350 case ScriptType::Ewpn:
40351 {
40352
40353 836 Ewpns.spr(EwpnH::getEWeaponIndex(i))->doscript = 0;
40354 836 Ewpns.spr(EwpnH::getEWeaponIndex(i))->weaponscript = 0;
40355 836 Ewpns.spr(EwpnH::getEWeaponIndex(i))->initialised = 0;
40356 836 break;
40357 }
40358 case ScriptType::ItemSprite:
40359 {
40360 40 items.spr(ItemH::getItemIndex(i))->doscript = 0;
40361 40 items.spr(ItemH::getItemIndex(i))->script = 0;
40362 40 items.spr(ItemH::getItemIndex(i))->initialised = 0;
40363 40 break;
40364 }
40365 }
40366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70477 times.
70477 if(!no_dealloc)
40367
3/3
✓ Branch 0 taken 69450 times.
✓ Branch 1 taken 1009 times.
✓ Branch 2 taken 18 times.
70477 switch(type)
40368 {
40369 case ScriptType::Item:
40370 {
40371
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
1009 bool collect = ( ( i < 1 ) || (i == COLLECT_SCRIPT_ITEM_ZERO) );
40372
3/4
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
✓ Branch 2 taken 194 times.
✗ Branch 3 not taken.
1009 int new_i = ( collect ) ? (( i != COLLECT_SCRIPT_ITEM_ZERO ) ? (i * -1) : 0) : i;
40373 1009 FFScript::deallocateAllScriptOwned(ScriptType::Item, new_i);
40374 1009 break;
40375 }
40376
40377 case ScriptType::Screen:
40378 {
40379 18 FFScript::deallocateAllScriptOwned(ScriptType::Screen, 0);
40380 18 break;
40381 }
40382
40383 default:
40384 69450 FFScript::deallocateAllScriptOwned(type, i);
40385 69450 break;
40386 70477 }
40387
40388 70477 return RUNSCRIPT_STOPPED;
40389 }
40390 else
40391 714744870 ri->pc++;
40392
40393 714744870 return RUNSCRIPT_OK;
40394 714815357 }
40395
40396 script_data* load_scrdata(ScriptType type, word script, int32_t i)
40397 {
40398 switch(type)
40399 {
40400 case ScriptType::FFC:
40401 return ffscripts[script];
40402 case ScriptType::NPC:
40403 return guyscripts[guys.spr(GuyH::getNPCIndex(i))->script];
40404 case ScriptType::Lwpn:
40405 return lwpnscripts[Lwpns.spr(LwpnH::getLWeaponIndex(i))->weaponscript];
40406 case ScriptType::Ewpn:
40407 return ewpnscripts[Ewpns.spr(EwpnH::getEWeaponIndex(i))->weaponscript];
40408 case ScriptType::ItemSprite:
40409 return itemspritescripts[items.spr(ItemH::getItemIndex(i))->script];
40410 case ScriptType::Item:
40411 return itemscripts[script];
40412 case ScriptType::Global:
40413 return globalscripts[script];
40414 case ScriptType::Generic:
40415 case ScriptType::GenericFrozen:
40416 return genericscripts[script];
40417 case ScriptType::Player:
40418 return playerscripts[script];
40419 case ScriptType::DMap:
40420 return dmapscripts[script];
40421 case ScriptType::OnMap:
40422 case ScriptType::ScriptedActiveSubscreen:
40423 case ScriptType::ScriptedPassiveSubscreen:
40424 return dmapscripts[script];
40425 case ScriptType::Screen:
40426 return screenscripts[script];
40427 case ScriptType::Combo:
40428 return comboscripts[script];
40429 case ScriptType::EngineSubscreen:
40430 return subscreenscripts[script];
40431 }
40432 return nullptr;
40433 }
40434
40435 //This keeps ffc scripts running beyond the first frame.
40436 7299804 int32_t ffscript_engine(const bool preload)
40437 {
40438
2/2
✓ Branch 0 taken 7284262 times.
✓ Branch 1 taken 15542 times.
7299804 if(preload)
40439 {
40440 15542 throwGenScriptEvent(GENSCR_EVENT_FFC_PRELOAD);
40441 15542 }
40442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7299804 times.
7299804 if (!FFCore.system_suspend[susptFFCSCRIPTS])
40443 {
40444 //run screen script, first
40445 //zprint("Screen Script Preload? %s \n", ( tmpscr->preloadscript ? "true" : "false"));
40446
4/4
✓ Branch 0 taken 15542 times.
✓ Branch 1 taken 7284262 times.
✓ Branch 2 taken 15529 times.
✓ Branch 3 taken 7268733 times.
7299804 if(( preload && tmpscr->preloadscript) || !preload )
40447 {
40448
2/2
✓ Branch 0 taken 6969052 times.
✓ Branch 1 taken 315223 times.
7284275 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
40449 {
40450
3/4
✓ Branch 0 taken 9269 times.
✓ Branch 1 taken 305954 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9269 times.
315223 if ( tmpscr->script > 0 && FFCore.doscript(ScriptType::Screen) )
40451 {
40452 9269 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script);
40453 9269 }
40454 315223 }
40455 7284275 }
40456 7299804 word c = tmpscr->numFFC();
40457
2/2
✓ Branch 0 taken 229218696 times.
✓ Branch 1 taken 7299804 times.
236518500 for(word i = 0; i < c; i++)
40458 {
40459
2/2
✓ Branch 0 taken 4718438 times.
✓ Branch 1 taken 224500258 times.
229218696 if(tmpscr->ffcs[i].script == 0)
40460 224500258 continue;
40461
40462
4/4
✓ Branch 0 taken 6100 times.
✓ Branch 1 taken 4712338 times.
✓ Branch 2 taken 1703 times.
✓ Branch 3 taken 4397 times.
4718438 if(preload && !(tmpscr->ffcs[i].flags&ffPRELOAD))
40463 4397 continue;
40464
40465
4/4
✓ Branch 0 taken 4709482 times.
✓ Branch 1 taken 4559 times.
✓ Branch 2 taken 4678182 times.
✓ Branch 3 taken 31300 times.
4714041 if((tmpscr->ffcs[i].flags&ffIGNOREHOLDUP)==0 && Hero.getHoldClk()>0)
40466 31300 continue;
40467
40468 4682741 ZScriptVersion::RunScript(ScriptType::FFC, tmpscr->ffcs[i].script, i);
40469 4682741 }
40470 7299804 }
40471
40472
40473 7299804 return 0;
40474 }
40475
40476
40477
40478 ///----------------------------------------------------------------------------------------------------
40479
40480 227 void FFScript::user_files_init()
40481 {
40482
2/2
✓ Branch 0 taken 58112 times.
✓ Branch 1 taken 227 times.
58339 for(int32_t q = 0; q < MAX_USER_FILES; ++q)
40483 {
40484 58112 script_files[q].clear();
40485 58112 }
40486 227 }
40487
40488 227 void FFScript::user_dirs_init()
40489 {
40490
2/2
✓ Branch 0 taken 58112 times.
✓ Branch 1 taken 227 times.
58339 for(int32_t q = 0; q < MAX_USER_DIRS; ++q)
40491 {
40492 58112 script_dirs[q].clear();
40493 58112 }
40494 227 }
40495 349 void FFScript::user_objects_init()
40496 {
40497
2/2
✓ Branch 0 taken 74947052 times.
✓ Branch 1 taken 349 times.
74947401 for(int32_t q = 0; q < MAX_USER_OBJECTS; ++q)
40498 {
40499 74947052 script_objects[q].clear_nodestruct();
40500 74947052 }
40501 349 max_valid_object = 0;
40502 349 }
40503
40504 227 void FFScript::user_stacks_init()
40505 {
40506
2/2
✓ Branch 0 taken 58112 times.
✓ Branch 1 taken 227 times.
58339 for(int32_t q = 0; q < MAX_USER_STACKS; ++q)
40507 {
40508 58112 script_stacks[q].clear();
40509 58112 }
40510 227 }
40511
40512 409 void FFScript::user_rng_init()
40513 {
40514
2/2
✓ Branch 0 taken 104704 times.
✓ Branch 1 taken 409 times.
105113 for(int32_t q = 0; q < MAX_USER_RNGS; ++q)
40515 {
40516 104704 replay_register_rng(&script_rnggens[q]);
40517 104704 script_rngs[q].clear();
40518 104704 script_rngs[q].set_gen(&script_rnggens[q]);
40519 104704 }
40520 409 }
40521
40522 227 void FFScript::user_paldata_init()
40523 {
40524
2/2
✓ Branch 0 taken 58112 times.
✓ Branch 1 taken 227 times.
58339 for (int32_t q = 0; q < MAX_USER_PALDATAS; ++q)
40525 {
40526 58112 script_paldatas[q].clear();
40527 58112 }
40528 227 }
40529
40530 2 int32_t FFScript::get_free_file(bool skipError)
40531 {
40532
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 for(int32_t q = 0; q < MAX_USER_FILES; ++q)
40533 {
40534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!script_files[q].reserved)
40535 {
40536 2 script_files[q].reserved = true;
40537 2 return q+1; //1-indexed; 0 is null value
40538 }
40539 }
40540 if(!skipError) Z_scripterrlog("get_free_file() could not find a valid free file pointer!\n");
40541 return 0;
40542 2 }
40543
40544 int32_t FFScript::get_free_object(bool skipError)
40545 {
40546 for(int32_t q = 0; q < MAX_USER_OBJECTS; ++q)
40547 {
40548 if(!script_objects[q].reserved)
40549 {
40550 script_objects[q].reserved = true;
40551 if(q >= max_valid_object)
40552 max_valid_object = q+1;
40553 return q+1; //1-indexed; 0 is null value
40554 }
40555 }
40556 if(!skipError) Z_scripterrlog("get_free_object() could not find a valid free object pointer!\n");
40557 return 0;
40558 }
40559
40560 int32_t FFScript::get_free_directory(bool skipError)
40561 {
40562 for(int32_t q = 0; q < MAX_USER_DIRS; ++q)
40563 {
40564 if(!script_dirs[q].reserved)
40565 {
40566 script_dirs[q].reserved = true;
40567 return q+1; //1-indexed; 0 is null value
40568 }
40569 }
40570 if(!skipError) Z_scripterrlog("get_free_directory() could not find a valid free directory pointer!\n");
40571 return 0;
40572 }
40573
40574 22 int32_t FFScript::get_free_rng(bool skipError)
40575 {
40576
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 for(int32_t q = 0; q < MAX_USER_RNGS; ++q)
40577 {
40578
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 22 times.
31 if(!script_rngs[q].reserved)
40579 {
40580 22 script_rngs[q].reserved = true;
40581 22 return q+1; //1-indexed; 0 is null value
40582 }
40583 9 }
40584 if(!skipError) Z_scripterrlog("get_free_rng() could not find a valid free rng pointer!\n");
40585 return 0;
40586 22 }
40587
40588 int32_t FFScript::get_free_paldata(bool skipError)
40589 {
40590 for (int32_t q = 0; q < MAX_USER_PALDATAS; ++q)
40591 {
40592 if (!script_paldatas[q].reserved)
40593 {
40594 script_paldatas[q].reserved = true;
40595 return q+1; //1-indexed; 0 is null value
40596 }
40597 }
40598 if (!skipError) Z_scripterrlog("get_free_paldata() could not find a valid free paldata pointer!\n");
40599 return 0;
40600 }
40601
40602 int32_t FFScript::get_free_stack(bool skipError)
40603 {
40604 for(int32_t q = 0; q < MAX_USER_STACKS; ++q)
40605 {
40606 if(!script_stacks[q].reserved)
40607 {
40608 script_stacks[q].reserved = true;
40609 return q+1; //1-indexed; 0 is null value
40610 }
40611 }
40612 if(!skipError) Z_scripterrlog("get_free_stack() could not find a valid free stack pointer!\n");
40613 return 0;
40614 }
40615
40616 // Gotten from 'https://fileinfo.com/filetypes/executable'
40617
187/376
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 116 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 116 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 116 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 116 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 116 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 116 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 116 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 116 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 116 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 116 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 116 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 116 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 116 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 116 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 116 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 116 times.
✗ Branch 37 not taken.
✓ Branch 38 taken 116 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 116 times.
✗ Branch 41 not taken.
✓ Branch 42 taken 116 times.
✗ Branch 43 not taken.
✓ Branch 44 taken 116 times.
✗ Branch 45 not taken.
✓ Branch 46 taken 116 times.
✗ Branch 47 not taken.
✓ Branch 48 taken 116 times.
✗ Branch 49 not taken.
✓ Branch 50 taken 116 times.
✗ Branch 51 not taken.
✓ Branch 52 taken 116 times.
✗ Branch 53 not taken.
✓ Branch 54 taken 116 times.
✗ Branch 55 not taken.
✓ Branch 56 taken 116 times.
✗ Branch 57 not taken.
✓ Branch 58 taken 116 times.
✗ Branch 59 not taken.
✓ Branch 60 taken 116 times.
✗ Branch 61 not taken.
✓ Branch 62 taken 116 times.
✗ Branch 63 not taken.
✓ Branch 64 taken 116 times.
✗ Branch 65 not taken.
✓ Branch 66 taken 116 times.
✗ Branch 67 not taken.
✓ Branch 68 taken 116 times.
✗ Branch 69 not taken.
✓ Branch 70 taken 116 times.
✗ Branch 71 not taken.
✓ Branch 72 taken 116 times.
✗ Branch 73 not taken.
✓ Branch 74 taken 116 times.
✗ Branch 75 not taken.
✓ Branch 76 taken 116 times.
✗ Branch 77 not taken.
✓ Branch 78 taken 116 times.
✗ Branch 79 not taken.
✓ Branch 80 taken 116 times.
✗ Branch 81 not taken.
✓ Branch 82 taken 116 times.
✗ Branch 83 not taken.
✓ Branch 84 taken 116 times.
✗ Branch 85 not taken.
✓ Branch 86 taken 116 times.
✗ Branch 87 not taken.
✓ Branch 88 taken 116 times.
✗ Branch 89 not taken.
✓ Branch 90 taken 116 times.
✗ Branch 91 not taken.
✓ Branch 92 taken 116 times.
✗ Branch 93 not taken.
✓ Branch 94 taken 116 times.
✗ Branch 95 not taken.
✓ Branch 96 taken 116 times.
✗ Branch 97 not taken.
✓ Branch 98 taken 116 times.
✗ Branch 99 not taken.
✓ Branch 100 taken 116 times.
✗ Branch 101 not taken.
✓ Branch 102 taken 116 times.
✗ Branch 103 not taken.
✓ Branch 104 taken 116 times.
✗ Branch 105 not taken.
✓ Branch 106 taken 116 times.
✗ Branch 107 not taken.
✓ Branch 108 taken 116 times.
✗ Branch 109 not taken.
✓ Branch 110 taken 116 times.
✗ Branch 111 not taken.
✓ Branch 112 taken 116 times.
✗ Branch 113 not taken.
✓ Branch 114 taken 116 times.
✗ Branch 115 not taken.
✓ Branch 116 taken 116 times.
✗ Branch 117 not taken.
✓ Branch 118 taken 116 times.
✗ Branch 119 not taken.
✓ Branch 120 taken 116 times.
✗ Branch 121 not taken.
✓ Branch 122 taken 116 times.
✗ Branch 123 not taken.
✓ Branch 124 taken 116 times.
✗ Branch 125 not taken.
✓ Branch 126 taken 116 times.
✗ Branch 127 not taken.
✓ Branch 128 taken 116 times.
✗ Branch 129 not taken.
✓ Branch 130 taken 116 times.
✗ Branch 131 not taken.
✓ Branch 132 taken 116 times.
✗ Branch 133 not taken.
✓ Branch 134 taken 116 times.
✗ Branch 135 not taken.
✓ Branch 136 taken 116 times.
✗ Branch 137 not taken.
✓ Branch 138 taken 116 times.
✗ Branch 139 not taken.
✓ Branch 140 taken 116 times.
✗ Branch 141 not taken.
✓ Branch 142 taken 116 times.
✗ Branch 143 not taken.
✓ Branch 144 taken 116 times.
✗ Branch 145 not taken.
✓ Branch 146 taken 116 times.
✗ Branch 147 not taken.
✓ Branch 148 taken 116 times.
✗ Branch 149 not taken.
✓ Branch 150 taken 116 times.
✗ Branch 151 not taken.
✓ Branch 152 taken 116 times.
✗ Branch 153 not taken.
✓ Branch 154 taken 116 times.
✗ Branch 155 not taken.
✓ Branch 156 taken 116 times.
✗ Branch 157 not taken.
✓ Branch 158 taken 116 times.
✗ Branch 159 not taken.
✓ Branch 160 taken 116 times.
✗ Branch 161 not taken.
✓ Branch 162 taken 116 times.
✗ Branch 163 not taken.
✓ Branch 164 taken 116 times.
✗ Branch 165 not taken.
✓ Branch 166 taken 116 times.
✗ Branch 167 not taken.
✓ Branch 168 taken 116 times.
✗ Branch 169 not taken.
✓ Branch 170 taken 116 times.
✗ Branch 171 not taken.
✓ Branch 172 taken 116 times.
✗ Branch 173 not taken.
✓ Branch 174 taken 116 times.
✗ Branch 175 not taken.
✓ Branch 176 taken 116 times.
✗ Branch 177 not taken.
✓ Branch 178 taken 116 times.
✗ Branch 179 not taken.
✓ Branch 180 taken 116 times.
✗ Branch 181 not taken.
✓ Branch 182 taken 116 times.
✗ Branch 183 not taken.
✓ Branch 184 taken 116 times.
✗ Branch 185 not taken.
✓ Branch 186 taken 116 times.
✗ Branch 187 not taken.
✓ Branch 188 taken 116 times.
✗ Branch 189 not taken.
✓ Branch 190 taken 116 times.
✗ Branch 191 not taken.
✓ Branch 192 taken 116 times.
✗ Branch 193 not taken.
✓ Branch 194 taken 116 times.
✗ Branch 195 not taken.
✓ Branch 196 taken 116 times.
✗ Branch 197 not taken.
✓ Branch 198 taken 116 times.
✗ Branch 199 not taken.
✓ Branch 200 taken 116 times.
✗ Branch 201 not taken.
✓ Branch 202 taken 116 times.
✗ Branch 203 not taken.
✓ Branch 204 taken 116 times.
✗ Branch 205 not taken.
✓ Branch 206 taken 116 times.
✗ Branch 207 not taken.
✓ Branch 208 taken 116 times.
✗ Branch 209 not taken.
✓ Branch 210 taken 116 times.
✗ Branch 211 not taken.
✓ Branch 212 taken 116 times.
✗ Branch 213 not taken.
✓ Branch 214 taken 116 times.
✗ Branch 215 not taken.
✓ Branch 216 taken 116 times.
✗ Branch 217 not taken.
✓ Branch 218 taken 116 times.
✗ Branch 219 not taken.
✓ Branch 220 taken 116 times.
✗ Branch 221 not taken.
✓ Branch 222 taken 116 times.
✗ Branch 223 not taken.
✓ Branch 224 taken 116 times.
✗ Branch 225 not taken.
✓ Branch 226 taken 116 times.
✗ Branch 227 not taken.
✓ Branch 228 taken 116 times.
✗ Branch 229 not taken.
✓ Branch 230 taken 116 times.
✗ Branch 231 not taken.
✓ Branch 232 taken 116 times.
✗ Branch 233 not taken.
✓ Branch 234 taken 116 times.
✗ Branch 235 not taken.
✓ Branch 236 taken 116 times.
✗ Branch 237 not taken.
✓ Branch 238 taken 116 times.
✗ Branch 239 not taken.
✓ Branch 240 taken 116 times.
✗ Branch 241 not taken.
✓ Branch 242 taken 116 times.
✗ Branch 243 not taken.
✓ Branch 244 taken 116 times.
✗ Branch 245 not taken.
✓ Branch 246 taken 116 times.
✗ Branch 247 not taken.
✓ Branch 248 taken 116 times.
✗ Branch 249 not taken.
✓ Branch 250 taken 116 times.
✗ Branch 251 not taken.
✓ Branch 252 taken 116 times.
✗ Branch 253 not taken.
✓ Branch 254 taken 116 times.
✗ Branch 255 not taken.
✓ Branch 256 taken 116 times.
✗ Branch 257 not taken.
✓ Branch 258 taken 116 times.
✗ Branch 259 not taken.
✓ Branch 260 taken 116 times.
✗ Branch 261 not taken.
✓ Branch 262 taken 116 times.
✗ Branch 263 not taken.
✓ Branch 264 taken 116 times.
✗ Branch 265 not taken.
✓ Branch 266 taken 116 times.
✗ Branch 267 not taken.
✓ Branch 268 taken 116 times.
✗ Branch 269 not taken.
✓ Branch 270 taken 116 times.
✗ Branch 271 not taken.
✓ Branch 272 taken 116 times.
✗ Branch 273 not taken.
✓ Branch 274 taken 116 times.
✗ Branch 275 not taken.
✓ Branch 276 taken 116 times.
✗ Branch 277 not taken.
✓ Branch 278 taken 116 times.
✗ Branch 279 not taken.
✓ Branch 280 taken 116 times.
✗ Branch 281 not taken.
✓ Branch 282 taken 116 times.
✗ Branch 283 not taken.
✓ Branch 284 taken 116 times.
✗ Branch 285 not taken.
✓ Branch 286 taken 116 times.
✗ Branch 287 not taken.
✓ Branch 288 taken 116 times.
✗ Branch 289 not taken.
✓ Branch 290 taken 116 times.
✗ Branch 291 not taken.
✓ Branch 292 taken 116 times.
✗ Branch 293 not taken.
✓ Branch 294 taken 116 times.
✗ Branch 295 not taken.
✓ Branch 296 taken 116 times.
✗ Branch 297 not taken.
✓ Branch 298 taken 116 times.
✗ Branch 299 not taken.
✓ Branch 300 taken 116 times.
✗ Branch 301 not taken.
✓ Branch 302 taken 116 times.
✗ Branch 303 not taken.
✓ Branch 304 taken 116 times.
✗ Branch 305 not taken.
✓ Branch 306 taken 116 times.
✗ Branch 307 not taken.
✓ Branch 308 taken 116 times.
✗ Branch 309 not taken.
✓ Branch 310 taken 116 times.
✗ Branch 311 not taken.
✓ Branch 312 taken 116 times.
✗ Branch 313 not taken.
✓ Branch 314 taken 116 times.
✗ Branch 315 not taken.
✓ Branch 316 taken 116 times.
✗ Branch 317 not taken.
✓ Branch 318 taken 116 times.
✗ Branch 319 not taken.
✓ Branch 320 taken 116 times.
✗ Branch 321 not taken.
✓ Branch 322 taken 116 times.
✗ Branch 323 not taken.
✓ Branch 324 taken 116 times.
✗ Branch 325 not taken.
✓ Branch 326 taken 116 times.
✗ Branch 327 not taken.
✓ Branch 328 taken 116 times.
✗ Branch 329 not taken.
✓ Branch 330 taken 116 times.
✗ Branch 331 not taken.
✓ Branch 332 taken 116 times.
✗ Branch 333 not taken.
✓ Branch 334 taken 116 times.
✗ Branch 335 not taken.
✓ Branch 336 taken 116 times.
✗ Branch 337 not taken.
✓ Branch 338 taken 116 times.
✗ Branch 339 not taken.
✓ Branch 340 taken 116 times.
✗ Branch 341 not taken.
✓ Branch 342 taken 116 times.
✗ Branch 343 not taken.
✓ Branch 344 taken 116 times.
✗ Branch 345 not taken.
✓ Branch 346 taken 116 times.
✗ Branch 347 not taken.
✓ Branch 348 taken 116 times.
✗ Branch 349 not taken.
✓ Branch 350 taken 116 times.
✗ Branch 351 not taken.
✓ Branch 352 taken 116 times.
✗ Branch 353 not taken.
✓ Branch 354 taken 116 times.
✗ Branch 355 not taken.
✓ Branch 356 taken 116 times.
✗ Branch 357 not taken.
✓ Branch 358 taken 116 times.
✗ Branch 359 not taken.
✓ Branch 360 taken 116 times.
✗ Branch 361 not taken.
✓ Branch 362 taken 116 times.
✗ Branch 363 not taken.
✓ Branch 364 taken 116 times.
✗ Branch 365 not taken.
✓ Branch 366 taken 116 times.
✗ Branch 367 not taken.
✓ Branch 368 taken 116 times.
✗ Branch 369 not taken.
✓ Branch 370 taken 116 times.
✗ Branch 371 not taken.
✓ Branch 372 taken 116 times.
✗ Branch 373 not taken.
✗ Branch 374 not taken.
✗ Branch 375 not taken.
116 static std::set<std::string> banned_extensions = {".xlm",".caction",".8ck", ".actc",".a6p", ".m3g",".run",".workflow",".otm",".apk",".fxp",".73k",".0xe",".exe",".cmd",".jsx",".scar",".wcm",".jar",".ebs2",".ipa",".xap",".ba_",".ac",".bin",".vlx",".icd",".elf",".xbap",".89k",".widget",".a7r",".ex_",".zl9",".cgi",".scr",".coffee",".ahk",".plsc",".air",".ear",".app",".scptd",".xys",".hms",".cyw",".ebm",".pwc",".xqt",".msl",".seed",".vexe",".ebs",".mcr",".gpu",".celx",".wsh",".frs",".vxp",".action",".com",".out",".gadget",".command",".script",".rfu",".tcp",".widget",".ex4",".bat",".cof",".phar",".rxe",".scb",".ms",".isu",".fas",".mlx",".gpe",".mcr",".mrp",".u3p",".js",".acr",".epk",".exe1",".jsf",".rbf",".rgs",".vpm",".ecf",".hta",".dld",".applescript",".prg",".pyc",".spr",".nexe",".server",".appimage",".pyo",".dek",".mrc",".fpi",".rpj",".iim",".vbs",".pif",".mel",".scpt",".csh",".paf",".ws",".mm",".acc",".ex5",".mac",".plx",".snap",".ps1",".vdo",".mxe",".gs",".osx",".sct",".wiz",".x86",".e_e",".fky",".prg",".fas",".azw2",".actm",".cel",".tiapp",".thm",".kix",".wsf",".vbe",".lo",".ls",".tms",".ezs",".ds",".n",".esh",".vbscript",".arscript",".qit",".pex",".dxl",".wpm",".s2a",".sca",".prc",".shb",".rbx",".jse",".beam",".udf",".mem",".kx",".ksh",".rox",".upx",".ms",".mam",".btm",".es",".asb",".ipf",".mio",".sbs",".hpf",".ita",".eham",".ezt",".dmc",".qpx",".ore",".ncl",".exopc",".smm",".pvd",".ham",".wpk"};
40618
40619 // Any extension other than banned ones, including no extension, is allowed.
40620 2 bool validate_userfile_extension(string const& path)
40621 {
40622
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 std::string ext = std::filesystem::path(path).extension().string();
40623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 return banned_extensions.find(ext) == banned_extensions.end();
40624 2 }
40625
40626 2 bool FFScript::get_scriptfile_path(char* buf, const char* path)
40627 {
40628
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 while((path[0] == '/' || path[0] == '\\') && path[0]) ++path;
40629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(path[0])
40630 2 sprintf(buf, "%s%c%s", qst_files_path, PATH_SLASH, path);
40631 else sprintf(buf, "%s", qst_files_path);
40632 2 return true;
40633 }
40634
40635 void check_file_error(int32_t ref)
40636 {
40637 if(user_file* f = checkFile(ref, "", true, true))
40638 {
40639 int32_t err = ferror(f->file);
40640 if(err != 0)
40641 {
40642 Z_scripterrlog("File with UID '%ld' encountered an error.\n", ref);
40643 Z_scripterrlog("File error: %s\n", strerror(err));
40644 }
40645 }
40646 }
40647
40648 2 void FFScript::do_fopen(const bool v, const char* f_mode)
40649 {
40650 2 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
40651 2 string filename_str;
40652
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 ArrayH::getString(arrayptr, filename_str, 512);
40653
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 regulate_path(filename_str);
40654 2 ri->d[rEXP1] = 0L; //Presume failure; update to 10000L on success
40655
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(!valid_file(filename_str))
40656 {
40657 Z_scripterrlog("Path '%s' empty or points to a directory; must point to a file!\n",filename_str.c_str());
40658 return;
40659 }
40660
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(!validate_userfile_extension(filename_str))
40661 {
40662 Z_scripterrlog("Cannot open/create file with extension '%s'.\n", get_ext(filename_str).c_str());
40663 return;
40664 }
40665
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(filename_str.find("../") != string::npos
40666
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 || filename_str.find("..\\") != string::npos)
40667 {
40668 Z_scripterrlog("Error: Script attempted to go up a directory in file load '%s'\n", filename_str.c_str());
40669 return;
40670 }
40671 2 char buf[2048+1] = {0};
40672 2 FFCore.get_scriptfile_path(buf, filename_str.c_str());
40673
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 user_file* f = checkFile(ri->fileref, "Open()", false, true);
40674
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!f) //auto-allocate
40675 {
40676
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 ri->fileref = get_free_file();
40677
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 f = checkFile(ri->fileref, "Open()", false, true);
40678 2 }
40679 2 ri->d[rEXP2] = ri->fileref; //Returns to the variable!
40680
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(f)
40681 {
40682
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 f->close(); //Close the old FILE* before overwriting it!
40683 2 bool create = false;
40684
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
5 for(int32_t q = 0; f_mode[q]; ++q)
40685 {
40686
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
4 if(f_mode[q] == 'w' || f_mode[q] == 'a')
40687 {
40688 1 create = true;
40689 1 break;
40690 }
40691 3 }
40692
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 if(!create || create_path(buf))
40693 {
40694
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 f->file = fopen(buf, f_mode);
40695
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 fflush(f->file);
40696
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 zc_chmod(buf, SCRIPT_FILE_MODE);
40697
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 f->setPath(buf);
40698 //r+; read-write, will not create if does not exist, will not delete content if does exist.
40699 //w+; read-write, will create if does not exist, will delete all content if does exist.
40700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(f->file)
40701 {
40702 ri->d[rEXP1] = 10000L; //Success
40703 return;
40704 }
40705 1 }
40706 else
40707 {
40708
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 Z_scripterrlog("Script failed to create directories for file path '%s'.\n", filename_str.c_str());
40709 1 return;
40710 }
40711 1 }
40712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 }
40713
40714 void FFScript::do_fremove()
40715 {
40716 if(user_file* f = checkFile(ri->fileref, "Remove()", true))
40717 {
40718 zprint2("Removing file %d\n", ri->fileref);
40719 ri->d[rEXP1] = f->do_remove() ? 0L : 10000L;
40720 }
40721 else ri->d[rEXP1] = 0L;
40722 }
40723
40724 void FFScript::do_fclose()
40725 {
40726 if(user_file* f = checkFile(ri->fileref, "Close()", false, true))
40727 {
40728 f->close();
40729 }
40730 //No else. If invalid, no error is thrown.
40731 }
40732
40733 void FFScript::do_allocate_file()
40734 {
40735 //Get a file and return it
40736 ri->fileref = get_free_file();
40737 ri->d[rEXP2] = ri->fileref; //Return to ptr
40738 ri->d[rEXP1] = (ri->d[rEXP2] == 0 ? 0L : 10000L);
40739 }
40740
40741 1 void FFScript::do_deallocate_file()
40742 {
40743 1 user_file* f = checkFile(ri->fileref, "Free()", false, true);
40744
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(f) f->clear();
40745 1 }
40746
40747 void FFScript::do_file_isallocated() //Returns true if file is allocated
40748 {
40749 user_file* f = checkFile(ri->fileref, "isAllocated()", false, true);
40750 ri->d[rEXP1] = (f) ? 10000L : 0L;
40751 }
40752
40753 void FFScript::do_file_isvalid() //Returns true if file is allocated and has an open FILE*
40754 {
40755 user_file* f = checkFile(ri->fileref, "isValid()", true, true);
40756 ri->d[rEXP1] = (f) ? 10000L : 0L;
40757 }
40758
40759 1 void FFScript::do_fflush()
40760 {
40761 1 ri->d[rEXP1] = 0L;
40762
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(user_file* f = checkFile(ri->fileref, "Flush()", true))
40763 {
40764 if(!fflush(f->file))
40765 ri->d[rEXP1] = 10000L;
40766 check_file_error(ri->fileref);
40767 }
40768 1 }
40769
40770 void FFScript::do_file_readchars()
40771 {
40772 if(user_file* f = checkFile(ri->fileref, "ReadChars()", true))
40773 {
40774 uint32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
40775 int32_t count = get_register(sarg2) / 10000;
40776 if(count == 0) return;
40777 int32_t arrayptr = get_register(sarg1) / 10000;
40778 ArrayManager am(arrayptr);
40779 int32_t sz = am.size();
40780 if(sz <= 0)
40781 return;
40782 if(pos >= sz)
40783 {
40784 Z_scripterrlog("Pos (%d) passed to %s is outside the bounds of array %d. Aborting.\n", pos, "ReadChars()", arrayptr);
40785 return;
40786 }
40787 if(count < 0 || unsigned(count) > sz-pos) count = sz-pos;
40788 int32_t limit = pos+count;
40789 char c;
40790 word q;
40791 ri->d[rEXP1] = 0;
40792 for(q = pos; q < limit; ++q)
40793 {
40794 c = fgetc(f->file);
40795 if(feof(f->file) || ferror(f->file))
40796 break;
40797 if(c <= 0)
40798 break;
40799 am.set(q,c * 10000L);
40800 ++ri->d[rEXP1]; //Don't count nullchar towards length
40801 }
40802 if(q >= limit)
40803 {
40804 --q;
40805 --ri->d[rEXP1];
40806 ungetc(am.get(q), f->file); //Put the character back before overwriting it
40807 }
40808 am.set(q,0); //Force null-termination
40809 ri->d[rEXP1] *= 10000L;
40810 check_file_error(ri->fileref);
40811 return;
40812 }
40813 ri->d[rEXP1] = 0L;
40814 }
40815 void FFScript::do_file_readbytes()
40816 {
40817 if(user_file* f = checkFile(ri->fileref, "ReadBytes()", true))
40818 {
40819 uint32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
40820 int32_t count = get_register(sarg2) / 10000;
40821 if(count == 0) return;
40822 int32_t arrayptr = get_register(sarg1) / 10000;
40823 ArrayManager am(arrayptr);
40824 int32_t sz = am.size();
40825 if(sz <= 0)
40826 return;
40827 if(pos >= sz)
40828 {
40829 Z_scripterrlog("Pos (%d) passed to %s is outside the bounds of array %d. Aborting.\n", pos, "ReadBytes()", arrayptr);
40830 return;
40831 }
40832 if(count < 0 || unsigned(count) > sz-pos) count = sz-pos;
40833 std::vector<uint8_t> data(count);
40834 ri->d[rEXP1] = 10000L * fread((void*)&(data[0]), 1, count, f->file);
40835 for(int32_t q = 0; q < count; ++q)
40836 {
40837 am.set(q+pos, 10000L * data[q]);
40838 }
40839 check_file_error(ri->fileref);
40840 return;
40841 }
40842 ri->d[rEXP1] = 0L;
40843 }
40844 void FFScript::do_file_readstring()
40845 {
40846 if(user_file* f = checkFile(ri->fileref, "ReadString()", true))
40847 {
40848 int32_t arrayptr = get_register(sarg1) / 10000;
40849 ArrayManager am(arrayptr);
40850 int32_t sz = am.size();
40851 if(sz <= 0)
40852 return;
40853 int32_t limit = sz;
40854 int32_t c;
40855 word q;
40856 ri->d[rEXP1] = 0;
40857 for(q = 0; q < limit; ++q)
40858 {
40859 c = fgetc(f->file);
40860 if(feof(f->file) || ferror(f->file))
40861 break;
40862 if(c <= 0)
40863 break;
40864 am.set(q,c * 10000L);
40865 ++ri->d[rEXP1]; //Don't count nullchar towards length
40866 if(c == '\n')
40867 {
40868 ++q;
40869 break;
40870 }
40871 }
40872 if(q >= limit)
40873 {
40874 --q;
40875 --ri->d[rEXP1];
40876 ungetc(am.get(q), f->file); //Put the character back before overwriting it
40877 }
40878 am.set(q,0); //Force null-termination
40879 ri->d[rEXP1] *= 10000L;
40880 check_file_error(ri->fileref);
40881 return;
40882 }
40883 ri->d[rEXP1] = 0L;
40884 }
40885 void FFScript::do_file_readints()
40886 {
40887 if(user_file* f = checkFile(ri->fileref, "ReadInts()", true))
40888 {
40889 uint32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
40890 int32_t count = get_register(sarg2) / 10000;
40891 if(count == 0) return;
40892 int32_t arrayptr = get_register(sarg1) / 10000;
40893 ArrayManager am(arrayptr);
40894 int32_t sz = am.size();
40895 if(sz <= 0)
40896 return;
40897 if(pos >= sz)
40898 {
40899 Z_scripterrlog("Pos (%d) passed to %s is outside the bounds of array %d. Aborting.\n", pos, "ReadInts()", arrayptr);
40900 return;
40901 }
40902 if(count < 0 || unsigned(count) > sz-pos) count = sz-pos;
40903
40904 std::vector<int32_t> data(count);
40905 ri->d[rEXP1] = 10000L * fread((void*)&(data[0]), 4, count, f->file);
40906 for(int32_t q = 0; q < count; ++q)
40907 {
40908 am.set(q+pos,data[q]);
40909 }
40910 check_file_error(ri->fileref);
40911 return;
40912 }
40913 ri->d[rEXP1] = 0L;
40914 }
40915 void FFScript::do_file_writechars()
40916 {
40917 if(user_file* f = checkFile(ri->fileref, "WriteChars()", true))
40918 {
40919 int32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
40920 int32_t count = get_register(sarg2) / 10000;
40921 if(count == 0) return;
40922 if(count == -1 || count > (MAX_ZC_ARRAY_SIZE-pos)) count = MAX_ZC_ARRAY_SIZE-pos;
40923 int32_t arrayptr = get_register(sarg1) / 10000;
40924 string output;
40925 ArrayH::getString(arrayptr, output, count, pos);
40926 uint32_t q = 0;
40927 for(; q < output.length(); ++q)
40928 {
40929 if(fputc(output[q], f->file)<0)
40930 break;
40931 }
40932 ri->d[rEXP1] = q * 10000L;
40933 check_file_error(ri->fileref);
40934 return;
40935 }
40936 ri->d[rEXP1] = 0L;
40937 }
40938
40939 void FFScript::do_file_writebytes()
40940 {
40941 if(user_file* f = checkFile(ri->fileref, "WriteBytes()", true))
40942 {
40943 uint32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
40944 int32_t arg = get_register(sarg2) / 10000;
40945 if(arg == 0) return;
40946 uint32_t count = ((arg<0 || unsigned(arg) >(MAX_ZC_ARRAY_SIZE - pos)) ? MAX_ZC_ARRAY_SIZE - pos : unsigned(arg));
40947 int32_t arrayptr = get_register(sarg1) / 10000;
40948 string output;
40949 ArrayManager am(arrayptr);
40950 if(am.invalid()) return;
40951 int32_t sz = am.size();
40952 if(sz <= 0)
40953 return;
40954 if(pos >= sz)
40955 {
40956 Z_scripterrlog("Pos (%d) passed to %s is outside the bounds of array %d. Aborting.\n", pos, "WriteBytes()", arrayptr);
40957 return;
40958 }
40959 if(count < 0 || unsigned(count) > sz-pos) count = sz-pos;
40960 std::vector<uint8_t> data(count);
40961 for(uint32_t q = 0; q < count; ++q)
40962 {
40963 data[q] = am.get(q+pos) / 10000;
40964 }
40965 ri->d[rEXP1] = 10000L * fwrite((const void*)&(data[0]), 1, count, f->file);
40966 check_file_error(ri->fileref);
40967 return;
40968 }
40969 ri->d[rEXP1] = 0L;
40970 }
40971 279 void FFScript::do_file_writestring()
40972 {
40973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279 times.
279 if(user_file* f = checkFile(ri->fileref, "WriteString()", true))
40974 {
40975 int32_t arrayptr = get_register(sarg1) / 10000;
40976 string output;
40977 ArrayH::getString(arrayptr, output, ZSCRIPT_MAX_STRING_CHARS);
40978 uint32_t q = 0;
40979 for(; q < output.length(); ++q)
40980 {
40981 if(fputc(output[q], f->file)<0)
40982 break;
40983 }
40984 ri->d[rEXP1] = q * 10000L;
40985 check_file_error(ri->fileref);
40986 return;
40987 }
40988 279 ri->d[rEXP1] = 0L;
40989 279 }
40990 void FFScript::do_file_writeints()
40991 {
40992 if(user_file* f = checkFile(ri->fileref, "WriteInts()", true))
40993 {
40994 uint32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
40995 int32_t count = get_register(sarg2) / 10000;
40996 if(count == 0) return;
40997 int32_t arrayptr = get_register(sarg1) / 10000;
40998 ArrayManager am(arrayptr);
40999 if(am.invalid()) return;
41000 int32_t sz = am.size();
41001 if(sz <= 0)
41002 return;
41003 if(pos >= sz)
41004 {
41005 Z_scripterrlog("Pos (%d) passed to %s is outside the bounds of array %d. Aborting.\n", pos, "WriteInts()", arrayptr);
41006 return;
41007 }
41008
41009 if(count < 0 || unsigned(count) > sz-pos) count = sz-pos;
41010 std::vector<int32_t> data(count);
41011 for(int32_t q = 0; q < count; ++q)
41012 {
41013 data[q] = am.get(q+pos);
41014 }
41015 ri->d[rEXP1] = 10000L * fwrite((const void*)&(data[0]), 4, count, f->file);
41016 check_file_error(ri->fileref);
41017 return;
41018 }
41019 ri->d[rEXP1] = 0L;
41020 }
41021
41022 void FFScript::do_file_getchar()
41023 {
41024 if(user_file* f = checkFile(ri->fileref, "GetChar()", true))
41025 {
41026 ri->d[rEXP1] = fgetc(f->file) * 10000L;
41027 check_file_error(ri->fileref);
41028 return;
41029 }
41030 ri->d[rEXP1] = -10000L; //-1 == EOF; error value
41031 }
41032 void FFScript::do_file_putchar()
41033 {
41034 if(user_file* f = checkFile(ri->fileref, "PutChar()", true))
41035 {
41036 int32_t c = get_register(sarg1) / 10000;
41037 if(char(c) != c)
41038 {
41039 Z_scripterrlog("Invalid character val %d passed to PutChar(); value will overflow.", c);
41040 c = char(c);
41041 }
41042 ri->d[rEXP1] = fputc(c, f->file) * 10000L;
41043 check_file_error(ri->fileref);
41044 return;
41045 }
41046 ri->d[rEXP1] = -10000L; //-1 == EOF; error value
41047 }
41048 void FFScript::do_file_ungetchar()
41049 {
41050 if(user_file* f = checkFile(ri->fileref, "UngetChar()", true))
41051 {
41052 int32_t c = get_register(sarg1) / 10000;
41053 if(char(c) != c)
41054 {
41055 Z_scripterrlog("Invalid character val %d passed to UngetChar(); value will overflow.", c);
41056 c = char(c);
41057 }
41058 ri->d[rEXP1] = ungetc(c,f->file) * 10000L;
41059 check_file_error(ri->fileref);
41060 return;
41061 }
41062 ri->d[rEXP1] = -10000L; //-1 == EOF; error value
41063 }
41064
41065 void FFScript::do_file_seek()
41066 {
41067 if(user_file* f = checkFile(ri->fileref, "Seek()", true))
41068 {
41069 int32_t pos = get_register(sarg1); //NOT /10000 -V
41070 int32_t origin = get_register(sarg2) ? SEEK_CUR : SEEK_SET;
41071 ri->d[rEXP1] = fseek(f->file, pos, origin) ? 0L : 10000L;
41072 check_file_error(ri->fileref);
41073 return;
41074 }
41075 ri->d[rEXP1] = 0;
41076 }
41077 void FFScript::do_file_rewind()
41078 {
41079 if(user_file* f = checkFile(ri->fileref, "Rewind()", true))
41080 {
41081 //fseek(f->file, 0L, SEEK_END);
41082 rewind(f->file);
41083 check_file_error(ri->fileref);
41084 }
41085 }
41086 void FFScript::do_file_clearerr()
41087 {
41088 if(user_file* f = checkFile(ri->fileref, "ClearError()", true))
41089 {
41090 clearerr(f->file);
41091 }
41092 }
41093
41094 void FFScript::do_file_geterr()
41095 {
41096 if(user_file* f = checkFile(ri->fileref, "GetError()", true))
41097 {
41098 int32_t err = ferror(f->file);
41099 int32_t arrayptr = get_register(sarg1) / 10000;
41100 if(err)
41101 {
41102 string error = strerror(err);
41103 ArrayH::setArray(arrayptr, error);
41104 }
41105 else
41106 {
41107 ArrayH::setArray(arrayptr, "\0");
41108 }
41109 }
41110 }
41111 ///----------------------------------------------------------------------------------------------------
41112 //Directory
41113
41114 void FFScript::do_directory_get()
41115 {
41116 if(user_dir* dr = checkDir(ri->directoryref, "GetFilename()", true))
41117 {
41118 int32_t indx = get_register(sarg1) / 10000L;
41119 int32_t arrayptr = get_register(sarg2) / 10000L;
41120 char buf[2048] = {0};
41121 set_register(sarg1, dr->get(indx, buf) ? 10000L : 0L);
41122 if(ArrayH::setArray(arrayptr, string(buf)) == SH::_Overflow)
41123 Z_scripterrlog("Array supplied to 'directory->GetFilename()' not large enough\n");
41124 }
41125 else set_register(sarg1, 0L);
41126 }
41127
41128 void FFScript::do_directory_reload()
41129 {
41130 if(user_dir* dr = checkDir(ri->directoryref, "Reload()", true))
41131 {
41132 dr->refresh();
41133 }
41134 }
41135
41136 void FFScript::do_directory_free()
41137 {
41138 if(user_dir* dr = checkDir(ri->directoryref, "Free()", true))
41139 {
41140 dr->clear();
41141 }
41142 }
41143
41144 ///----------------------------------------------------------------------------------------------------
41145
41146
41147 void FFScript::do_write_bitmap()
41148 {
41149 // for ( int32_t q = 0; q < 16; q++)
41150 // zprint("do_write_bitmap stack sp+%d: %d\n", q, SH::read_stack(ri->sp+q));
41151 int32_t arrayptr = get_register(sarg2) / 10000;
41152 string filename_str;
41153
41154 ArrayH::getString(arrayptr, filename_str, 512);
41155 int32_t ref = ri->bitmapref-10;
41156 // zprint("WriteBitmap() filename is %s\n",filename_str.c_str());
41157 // zprint("WriteBitmap ri->bitmapref is: %d\n",ref );
41158 if ( ref <= 0 )
41159 {
41160 if (ref == -2 )
41161 {
41162 save_bitmap(filename_str.c_str(), framebuf, RAMpal);
41163 // zprint("Wrote image file %s\n",filename_str.c_str());
41164 }
41165 else
41166 {
41167 Z_scripterrlog("WriteBitmap() failed to write image file %s\n",filename_str.c_str());
41168 }
41169 }
41170 else if ( ref >= 7 )
41171 {
41172 if ( scb.script_created_bitmaps[ref].u_bmp )
41173 {
41174 save_bitmap(filename_str.c_str(), scb.script_created_bitmaps[ri->bitmapref-10].u_bmp, RAMpal);
41175 // zprint("Wrote image file %s\n",filename_str.c_str());
41176 }
41177 else
41178 {
41179 Z_scripterrlog("WriteBitmap() failed to write image file %s\n",filename_str.c_str());
41180 }
41181 }
41182 else
41183 {
41184 if ( zscriptDrawingRenderTarget->GetBitmapPtr(ref) )
41185 {
41186 save_bitmap(filename_str.c_str(), zscriptDrawingRenderTarget->GetBitmapPtr(ref), RAMpal);
41187 // zprint("Wrote image file %s\n",filename_str.c_str());
41188 }
41189 else
41190 {
41191 Z_scripterrlog("WriteBitmap() failed to write image file %s\n",filename_str.c_str());
41192 }
41193 }
41194 }
41195
41196 void FFScript::set_sarg1(int32_t v)
41197 {
41198 set_register(sarg1, v);
41199 }
41200
41201 //script_bitmaps scb;
41202
41203 125 int32_t FFScript::do_allocate_bitmap()
41204 {
41205 125 return FFCore.get_free_bitmap();
41206 }
41207 5 void FFScript::do_isvalidbitmap()
41208 {
41209 5 int32_t UID = get_register(sarg1);
41210 //zprint("isValidBitmap() bitmap pointer value is %d\n", UID);
41211
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if ( UID <= 0 ) set_register(sarg1, 0);
41212 else if ( scb.script_created_bitmaps[UID-10].u_bmp )
41213 set_register(sarg1, 10000);
41214 else set_register(sarg1, 0);
41215 5 }
41216 43 void FFScript::do_isallocatedbitmap()
41217 {
41218 43 int32_t UID = get_register(sarg1);
41219 //zprint("isAllocatedBitmap() bitmap pointer value is %d\n", UID);
41220
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 42 times.
43 if ( UID <= 0 ) set_register(sarg1, 0);
41221 else
41222 {
41223 42 set_register(sarg1, (scb.script_created_bitmaps[UID-10].reserved()) ? 10000L : 0L);
41224 /*
41225 UID-=10;
41226 if ( UID <= highest_valid_user_bitmap() || UID < firstUserGeneratedBitmap)
41227 set_register(sarg1, 10000);
41228 else set_register(sarg1, 0);
41229 */
41230
41231 }
41232 43 }
41233
41234 227 void FFScript::user_bitmaps_init()
41235 {
41236 227 scb.clear();
41237 227 }
41238
41239 3670 int32_t FFScript::do_create_bitmap()
41240 {
41241 //zprint("Begin running FFCore.do_create_bitmap()\n");
41242 //CreateBitmap(h,w)
41243 3670 int32_t w = (ri->d[rINDEX2] / 10000);
41244 3670 int32_t h = (ri->d[rINDEX]/10000);
41245
1/2
✓ Branch 0 taken 3670 times.
✗ Branch 1 not taken.
3670 if ( get_qr(qr_OLDCREATEBITMAP_ARGS) )
41246 {
41247 //flip height and width
41248 h = h ^ w;
41249 w = h ^ w;
41250 h = h ^ w;
41251 }
41252
41253 3670 return create_user_bitmap_ex(h,w,8);
41254 }
41255
41256 3670 int32_t FFScript::create_user_bitmap_ex(int32_t w, int32_t h, int32_t d = 8)
41257 {
41258 3670 int32_t id = get_free_bitmap();
41259
1/2
✓ Branch 0 taken 3670 times.
✗ Branch 1 not taken.
3670 if ( id > 0 )
41260 {
41261 3670 user_bitmap* bmp = &(scb.script_created_bitmaps[id-10]);
41262 3670 bmp->width = w;
41263 3670 bmp->height = h;
41264 3670 bmp->depth = d;
41265 3670 bmp->u_bmp = create_bitmap_ex(d,w,h);
41266 3670 clear_bitmap(bmp->u_bmp);
41267 3670 }
41268 3670 return id;
41269 }
41270
41271 616532 BITMAP* FFScript::GetScriptBitmap(int32_t id, bool skipError)
41272 {
41273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 616532 times.
616532 switch(id)
41274 {
41275 case rtSCREEN:
41276 case rtBMP0:
41277 case rtBMP1:
41278 case rtBMP2:
41279 case rtBMP3:
41280 case rtBMP4:
41281 case rtBMP5:
41282 case rtBMP6: //old system bitmaps (render targets)
41283 {
41284 return zscriptDrawingRenderTarget->GetBitmapPtr(id);
41285 }
41286 default:
41287 {
41288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 616532 times.
616532 if(user_bitmap* b = checkBitmap(id+10, NULL, true, skipError))
41289 {
41290 616532 return b->u_bmp;
41291 }
41292 else return NULL;
41293 }
41294 }
41295 616532 }
41296
41297 3795 int32_t FFScript::get_free_bitmap(bool skipError)
41298 {
41299 3795 user_bitmap* bmps = scb.script_created_bitmaps;
41300
1/2
✓ Branch 0 taken 63470 times.
✗ Branch 1 not taken.
63470 for(int32_t q = MIN_USER_BITMAPS; q < MAX_USER_BITMAPS; ++q)
41301 {
41302
2/2
✓ Branch 0 taken 59675 times.
✓ Branch 1 taken 3795 times.
63470 if(!bmps[q].reserved())
41303 {
41304 3795 bmps[q].reserve();
41305 3795 return q+10;
41306 }
41307 59675 }
41308 if(!skipError) Z_scripterrlog("get_free_bitmap() could not find a valid free bitmap pointer!\n");
41309 return 0;
41310 3795 }
41311
41312 3512 void FFScript::do_deallocate_bitmap()
41313 {
41314
1/2
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
3512 if(isSystemBitref(ri->bitmapref))
41315 {
41316 return; //Don't attempt to deallocate system bitmaps!
41317 }
41318 3512 user_bitmap* b = checkBitmap(ri->bitmapref, "Free()", false, true);
41319
1/2
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
3512 if(b)
41320 {
41321 3512 b->free_obj();
41322 3512 }
41323 3512 }
41324
41325 3658 bool FFScript::isSystemBitref(int32_t ref)
41326 {
41327
1/2
✓ Branch 0 taken 3658 times.
✗ Branch 1 not taken.
3658 switch(ref-10)
41328 {
41329 case rtSCREEN:
41330 case rtBMP0:
41331 case rtBMP1:
41332 case rtBMP2:
41333 case rtBMP3:
41334 case rtBMP4:
41335 case rtBMP5:
41336 case rtBMP6:
41337 return true;
41338 }
41339 3658 return false;
41340 3658 }
41341
41342 ///----------------------------------------------------------------------------------------------------
41343
41344 void FFScript::set_screenwarpReturnY(mapscr *m, int32_t d, int32_t value)
41345 {
41346 int32_t y = vbound(value, 0, 255); //should be screen hight max, except that we may be able to move the subscreen.
41347 m->warpreturny[d] = y;
41348 }
41349
41350 void FFScript::set_screendoor(mapscr *m, int32_t d, int32_t value)
41351 {
41352 int32_t dr = vbound(d,0,3);
41353 int32_t doortype = vbound(value,0,14);
41354 m->door[dr] = doortype;
41355 }
41356
41357
41358 void FFScript::set_screenenemy(mapscr *m, int32_t index, int32_t value)
41359 {
41360 int32_t enem_indx = vbound(index,0,9);
41361 m->enemy[enem_indx] = vbound(value,0,511);
41362 }
41363 void FFScript::set_screenlayeropacity(mapscr *m, int32_t d, int32_t value)
41364 {
41365 int32_t layer = vbound(d,0,6); int32_t op;
41366 if ( value <= 64 ) op = 64;
41367 else op = 128;
41368 m->layeropacity[layer] = op;
41369 }
41370 void FFScript::set_screensecretcombo(mapscr *m, int32_t d, int32_t value)
41371 {
41372 int32_t indx = vbound(value,0,127);
41373 int32_t cmb = vbound(value,0,MAXCOMBOS);
41374 m->secretcombo[indx] = cmb;
41375 }
41376 void FFScript::set_screensecretcset(mapscr *m, int32_t d, int32_t value)
41377 {
41378 int32_t indx = vbound(value,0,127);
41379 int32_t cs = vbound(value,0,15);
41380 m->secretcset[indx] = cs;
41381 }
41382 void FFScript::set_screensecretflag(mapscr *m, int32_t d, int32_t value)
41383 {
41384 int32_t indx = vbound(d,0,127);
41385 int32_t flag = vbound(value,0,MAX_FLAGS);
41386 m->secretflag[indx] = flag;
41387 }
41388 void FFScript::set_screenlayermap(mapscr *m, int32_t d, int32_t value)
41389 {
41390 int32_t layer = vbound(d, MIN_ZQ_LAYER, MAX_ZQ_LAYER);
41391 int32_t mp = vbound(value,0, (map_count-1));
41392 m->layermap[layer] = mp;
41393 }
41394 void FFScript::set_screenlayerscreen(mapscr *m, int32_t d, int32_t value)
41395 {
41396 int32_t layer = vbound(d, MIN_ZQ_LAYER, MAX_ZQ_LAYER);
41397 int32_t sc = vbound(value,0, 0x87);
41398 m->layerscreen[layer] = sc;
41399 }
41400 void FFScript::set_screenpath(mapscr *m, int32_t d, int32_t value)
41401 {
41402 int32_t indx = vbound(d,0,3);
41403 m->path[indx] = value;
41404 }
41405 void FFScript::set_screenwarpReturnX(mapscr *m, int32_t d, int32_t value)
41406 {
41407 int32_t x = vbound(value,0,255);
41408 m->warpreturnx[d] = x;
41409 }
41410
41411
41412 void FFScript::set_screenGuy(mapscr *m, int32_t value)
41413 {
41414 int32_t bloke = vbound(value,0,9);
41415 m->guy = bloke ;
41416 }
41417 void FFScript::set_screenString(mapscr *m, int32_t value)
41418 {
41419 int32_t string = vbound(value, 0, msg_count-1); //Sanity check to keep it within the legal string IDs.
41420 m->str = string;
41421 }
41422 void FFScript::set_screenRoomtype(mapscr *m, int32_t value)
41423 {
41424 int32_t r = vbound(value, rNONE, (rMAX-1));
41425 m->room = r;
41426 }
41427 void FFScript::set_screenEntryX(mapscr *m, int32_t value)
41428 {
41429 int32_t x = vbound(value,0,255);
41430 m->entry_x = x;
41431 }
41432 void FFScript::set_screenEntryY(mapscr *m, int32_t value)
41433 {
41434 int32_t y = vbound(value,0,255);
41435 m->entry_y = y;
41436 }
41437 void FFScript::set_screenitem(mapscr *m, int32_t value)
41438 {
41439 int32_t itm = vbound(value,0,MAXITEMS);
41440 m->item = itm;
41441 }
41442 void FFScript::set_screenundercombo(mapscr *m, int32_t value)
41443 {
41444 int32_t cmb = vbound(value,0,MAXCOMBOS);
41445 m->undercombo = cmb;
41446 }
41447 void FFScript::set_screenundercset(mapscr *m, int32_t value)
41448 {
41449 int32_t cs = vbound(value,0,15);
41450 m->undercset = cs;
41451 }
41452 void FFScript::set_screenatchall(mapscr *m, int32_t value)
41453 {
41454 //What are ALL of the catchalls and their max (used) values?
41455 int32_t ctch = vbound(value, 0, 65535); //It is a word type.
41456 m->catchall = ctch;
41457 }
41458
41459
41460 //One too many inputs here. -Z
41461
41462 1051 int32_t FFScript::GetQuestVersion()
41463 {
41464 1051 return QHeader.zelda_version;
41465 }
41466 720 int32_t FFScript::GetQuestBuild()
41467 {
41468 720 return QHeader.build;
41469 }
41470 int32_t FFScript::GetQuestSectionVersion(int32_t section)
41471 {
41472 return QHeader.zelda_version;
41473 }
41474
41475 int32_t FFScript::GetDefaultWeaponSprite(int32_t wpn_id)
41476 {
41477 switch (wpn_id)
41478 {
41479 case wNone:
41480 return 0;
41481
41482 case wSword: return 0;
41483 case wBeam: return 1;
41484 case wBrang: return 4;
41485 case wBomb: return 9;
41486 case wSBomb: return 75;
41487 case wLitBomb: return 7;
41488 case wLitSBomb: return 8;
41489 case wArrow: return 10;
41490 case wFire: return 12;
41491 case wWhistle: return 45; //blank, unused misc sprite
41492 case wBait: return 14;
41493 case wWand: return 15;
41494 case wMagic: return 16;
41495 case wCatching: return 45; //blank, unused misc sprite
41496 case wWind: return 13;
41497 case wRefMagic: return 16;
41498 case wRefFireball: return 17;
41499 case wRefRock: return 18;
41500 case wHammer: return 25;
41501 case wHookshot: return 26;
41502 case wHSHandle: return 28;
41503 case wHSChain: return 27;
41504 case wSSparkle: return 29;
41505 case wFSparkle: return 32;
41506 case wSmack: return 33;
41507 case wPhantom: return -1;
41508 case wCByrna: return 87;
41509 case wRefBeam: return 1;
41510 case wStomp: return 45; //blank, unused misc sprite
41511 case lwMax: return 45; //blank, unused misc sprite
41512 case wScript1: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 246; else return 0; }
41513 case wScript2: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 247; else return 0; }
41514 case wScript3: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 248; else return 0; }
41515 case wScript4: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 249; else return 0; }
41516 case wScript5: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 250; else return 0; }
41517 case wScript6: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 251; else return 0; }
41518 case wScript7: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 252; else return 0; }
41519 case wScript8: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 253; else return 0; }
41520 case wScript9: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 254; else return 0; }
41521 case wScript10: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 255; else return 0; }
41522
41523 case wIce: return 83;
41524 //Cannot use any of these weapons yet.
41525 //return -1;
41526
41527 case wEnemyWeapons:
41528 case ewFireball: return 17;
41529
41530 case ewArrow: return 19;
41531 case ewBrang: return 4;
41532 case ewSword: return 20;
41533 case ewRock: return 18;
41534 case ewMagic: return 21;
41535 case ewBomb: return 78;
41536 case ewSBomb: return 79;
41537 case ewLitBomb: return 76;
41538 case ewLitSBomb: return 77;
41539 case ewFireTrail: return 80;
41540 case ewFlame: return 35;
41541 case ewWind: return 36;
41542 case ewFlame2: return 81;
41543 case ewFlame2Trail: return 82;
41544 case ewIce: return 83;
41545 case ewFireball2: return 17; //fireball (rising)
41546
41547
41548 default: return -1; //No assign.
41549
41550 }
41551 }
41552
41553 //bitmap->GetPixel()
41554
41555
41556 int32_t FFScript::do_getpixel()
41557 {
41558 int32_t xoffset = 0, yoffset = 0;
41559 int32_t xoff = 0; int32_t yoff = 0;
41560 const bool brokenOffset= ( (get_er(er_BITMAPOFFSET)!=0)
41561 || (get_qr(qr_BITMAPOFFSETFIX)!=0) );
41562
41563 BITMAP *bitty = FFCore.GetScriptBitmap(ri->bitmapref-10);
41564 if(!bitty)
41565 {
41566 bitty = scrollbuf;
41567 }
41568 // draw to screen with subscreen offset
41569 if(!brokenOffset && ri->bitmapref == 10-1 )
41570 {
41571 xoffset = xoff;
41572 yoffset = 56; //should this be -56?
41573 }
41574 else
41575 {
41576 xoffset = 0;
41577 yoffset = 0;
41578 }
41579
41580 int32_t yv = ri->d[rINDEX2]/10000 + yoffset;
41581 int32_t ret = getpixel(bitty, ri->d[rINDEX]/10000, yv); //This is a palette index value.
41582 if(!get_qr(qr_BROKEN_GETPIXEL_VALUE))
41583 ret *= 10000;
41584 return ret;
41585 }
41586
41587 void FFScript::do_bmpcollision()
41588 {
41589 int32_t bmpref = SH::read_stack(ri->sp + 5);
41590 int32_t maskbmpref = SH::read_stack(ri->sp + 4);
41591 int32_t x = SH::read_stack(ri->sp + 3) / 10000;
41592 int32_t y = SH::read_stack(ri->sp + 2) / 10000;
41593 int32_t checkCol = SH::read_stack(ri->sp + 1) / 10000;
41594 int32_t maskCol = SH::read_stack(ri->sp + 0) / 10000;
41595 BITMAP *checkbit = FFCore.GetScriptBitmap(bmpref-10, true);
41596 BITMAP *maskbit = FFCore.GetScriptBitmap(maskbmpref-10, true);
41597 if(!(checkbit && maskbit))
41598 {
41599 set_register(sarg1, -10000);
41600 char buf1[16];
41601 char buf2[16];
41602 zc_itoa(bmpref, buf1);
41603 zc_itoa(maskbmpref, buf2);
41604 Z_scripterrlog("Invalid bitmap%s passed to 'bitmap->CountColor()': %s%s%s\n",
41605 (checkbit || maskbit) ? "" : "s", checkbit ? "" : buf1,
41606 (checkbit || maskbit) ? "" : ", ", maskbit ? "" : buf2);
41607 return;
41608 }
41609 int32_t ret = countColor(checkbit, maskbit, x, y, checkCol, maskCol);
41610 set_register(sarg1, ret*10000);
41611 }
41612
41613
41614 6554876 int32_t FFScript::loadMapData()
41615 {
41616 6554876 int32_t _map = (ri->d[rINDEX] / 10000);
41617 6554876 int32_t _scr = (ri->d[rINDEX2]/10000);
41618
1/2
✓ Branch 0 taken 6554876 times.
✗ Branch 1 not taken.
6554876 int32_t indx = (zc_max((_map)-1,0) * MAPSCRS + _scr);
41619 //zprint("LoadMapData Map Value: %d\n", _map);
41620 //zprint("LoadMapData Screen Value: %d\n", _scr);
41621 //zprint("LoadMapData Indx Value: %d\n", indx);
41622
2/4
✓ Branch 0 taken 6554876 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6554876 times.
6554876 if ( _map < 1 || _map > map_count )
41623 {
41624 Z_scripterrlog("Invalid Map ID passed to Game->LoadMapData: %d\n", _map);
41625 ri->mapsref = MAX_SIGNED_32;
41626 }
41627
2/4
✓ Branch 0 taken 6554876 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6554876 times.
6554876 else if ( _scr < 0 || _scr > 129 ) //0x00 to 0x81 -Z
41628 {
41629 Z_scripterrlog("Invalid Screen ID passed to Game->LoadMapData: %d\n", _scr);
41630 ri->mapsref = MAX_SIGNED_32;
41631 }
41632 6554876 else ri->mapsref = indx;
41633 //zprint("LoadMapData Screen set ri->mapsref to: %d\n", ri->mapsref);
41634 6554876 return ri->mapsref;
41635 }
41636
41637
41638 // Called when leaving a screen; deallocate arrays created by FFCs that aren't carried over
41639 7000433 void FFScript::deallocateZScriptArray(const int32_t ptrval)
41640 {
41641
1/2
✓ Branch 0 taken 7000433 times.
✗ Branch 1 not taken.
7000433 if(ptrval == 0) return;
41642
2/4
✓ Branch 0 taken 7000433 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7000433 times.
7000433 if(ptrval==0 || ptrval >= NUM_ZSCRIPT_ARRAYS)
41643 Z_scripterrlog("Script tried to deallocate memory at invalid address %ld\n", ptrval);
41644
1/2
✓ Branch 0 taken 7000433 times.
✗ Branch 1 not taken.
7000433 else if(ptrval<0)
41645 Z_scripterrlog("Script tried to deallocate memory at object-based address %ld\n", ptrval);
41646 else
41647 {
41648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7000433 times.
7000433 if(arrayOwner[ptrval].specOwned) return; //ignore this deallocation
41649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7000433 times.
7000433 if(arrayOwner[ptrval].specCleared) return;
41650 7000433 arrayOwner[ptrval].clear();
41651
41652
1/2
✓ Branch 0 taken 7000433 times.
✗ Branch 1 not taken.
7000433 if(!localRAM[ptrval].Valid())
41653 Z_scripterrlog("Script tried to deallocate memory that was not allocated at address %ld\n", ptrval);
41654 else
41655 7000433 localRAM[ptrval].Clear();
41656 }
41657 7000433 }
41658
41659 433275 int32_t FFScript::get_screen_d(int32_t index1, int32_t index2)
41660 {
41661
3/4
✓ Branch 0 taken 433275 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 433272 times.
433275 if(index2 < 0 || index2 > 7)
41662 {
41663 3 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", index1);
41664 3 return 0;
41665 }
41666
41667 433272 return game->screen_d[index1][index2];
41668 433275 }
41669
41670 42105 void FFScript::set_screen_d(int32_t index1, int32_t index2, int32_t val)
41671 {
41672
2/4
✓ Branch 0 taken 42105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42105 times.
42105 if(index2 < 0 || index2 > 7)
41673 {
41674 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", index1);
41675 return;
41676 }
41677
41678 42105 game->screen_d[index1][index2] = val;
41679 42105 }
41680
41681 // If scr is currently being used as a layer, return that layer no.
41682 int32_t FFScript::whichlayer(int32_t scr)
41683 {
41684 for(int32_t i = 0; i < 6; i++)
41685 {
41686 if(scr == (tmpscr->layermap[i] - 1) * MAPSCRS + tmpscr->layerscreen[i])
41687 return i;
41688 }
41689
41690 return -1;
41691 }
41692
41693 void FFScript::do_zapout()
41694 {
41695 zapout();
41696 }
41697
41698 void FFScript::do_zapin(){ zapin(); }
41699
41700 void FFScript::do_openscreen() { openscreen(); }
41701 void FFScript::do_closescreen() { closescreen(); }
41702 void FFScript::do_openscreenshape()
41703 {
41704 int32_t shape = get_register(sarg1) / 10000;
41705 if(shape < 0 || shape >= bosMAX)
41706 {
41707 Z_scripterrlog("Invalid shape passed to %s! Valid range %d to %d. Using 'Circle' shape.\n", "Screen->OpeningWipe(int32_t)", 0, bosMAX-1);
41708 shape = bosCIRCLE;
41709 }
41710 openscreen(shape);
41711 }
41712 void FFScript::do_closescreenshape()
41713 {
41714 int32_t shape = get_register(sarg1) / 10000;
41715 if(shape < 0 || shape >= bosMAX)
41716 {
41717 Z_scripterrlog("Invalid shape passed to %s! Valid range %d to %d. Using 'Circle' shape.\n", "Screen->ClosingWipe(int32_t)", 0, bosMAX-1);
41718 shape = bosCIRCLE;
41719 }
41720 closescreen(shape);
41721 }
41722 void FFScript::do_wavyin() { wavyin(); }
41723 void FFScript::do_wavyout() { wavyout(false); }
41724
41725
41726 void FFScript::do_triggersecret(const bool v)
41727 {
41728 int32_t ID = vbound((SH::get_arg(sarg1, v) / 10000), 0, 255);
41729 mapscr *s = tmpscr;
41730 int32_t ft=0, checkflag; //Flag trigger, checked flag temp.
41731 bool putit = true; //Is set false with a mismatch (illegal value input).
41732 //Convert a flag type to a secret type. -Z
41733 switch(ID)
41734 {
41735 case mfANYFIRE:
41736 ft=sBCANDLE;
41737 break;
41738
41739 case mfSTRONGFIRE:
41740 ft=sRCANDLE;
41741 break;
41742
41743 case mfMAGICFIRE:
41744 ft=sWANDFIRE;
41745 break;
41746
41747 case mfDIVINEFIRE:
41748 ft=sDIVINEFIRE;
41749 break;
41750
41751 case mfARROW:
41752 ft=sARROW;
41753 break;
41754
41755 case mfSARROW:
41756 ft=sSARROW;
41757 break;
41758
41759 case mfGARROW:
41760 ft=sGARROW;
41761 break;
41762
41763 case mfSBOMB:
41764 ft=sSBOMB;
41765 break;
41766
41767 case mfBOMB:
41768 ft=sBOMB;
41769 break;
41770
41771 case mfBRANG:
41772 ft=sBRANG;
41773 break;
41774
41775 case mfMBRANG:
41776 ft=sMBRANG;
41777 break;
41778
41779 case mfFBRANG:
41780 ft=sFBRANG;
41781 break;
41782
41783 case mfWANDMAGIC:
41784 ft=sWANDMAGIC;
41785 break;
41786
41787 case mfREFMAGIC:
41788 ft=sREFMAGIC;
41789 break;
41790
41791 case mfREFFIREBALL:
41792 ft=sREFFIREBALL;
41793 break;
41794
41795 case mfSWORD:
41796 ft=sSWORD;
41797 break;
41798
41799 case mfWSWORD:
41800 ft=sWSWORD;
41801 break;
41802
41803 case mfMSWORD:
41804 ft=sMSWORD;
41805 break;
41806
41807 case mfXSWORD:
41808 ft=sXSWORD;
41809 break;
41810
41811 case mfSWORDBEAM:
41812 ft=sSWORDBEAM;
41813 break;
41814
41815 case mfWSWORDBEAM:
41816 ft=sWSWORDBEAM;
41817 break;
41818
41819 case mfMSWORDBEAM:
41820 ft=sMSWORDBEAM;
41821 break;
41822
41823 case mfXSWORDBEAM:
41824 ft=sXSWORDBEAM;
41825 break;
41826
41827 case mfHOOKSHOT:
41828 ft=sHOOKSHOT;
41829 break;
41830
41831 case mfWAND:
41832 ft=sWAND;
41833 break;
41834
41835 case mfHAMMER:
41836 ft=sHAMMER;
41837 break;
41838
41839 case mfSTRIKE:
41840 ft=sSTRIKE;
41841 break;
41842
41843 default:
41844 putit = false;
41845 break;
41846 }
41847 if ( putit )
41848 {
41849 for(int32_t iter=0; iter<2; ++iter)
41850 {
41851 for ( int32_t q = 0; q < 176; q++ )
41852 {
41853 if(iter==1) checkflag=s->sflag[q]; //Placed
41854 else checkflag=combobuf[s->data[q]].flag; //Inherent
41855 Z_message("checkflag is: %d\n", checkflag);
41856 al_trace("checkflag is: %d\n", checkflag);
41857
41858 Z_message("ID is: %ld\n", ID);
41859 al_trace("ID is: %d\n", ID);
41860 //cmbx = COMBOX(q);
41861 ////cmby = COMBOY(q);
41862
41863 //Placed flags
41864 if ( iter == 1 )
41865 {
41866 if ( s->sflag[q] == ID ) {
41867 screen_combo_modify_preroutine(s,q);
41868 s->data[q] = s->secretcombo[ft];
41869 s->cset[q] = s->secretcset[ft];
41870 s->sflag[q] = s->secretflag[ft];
41871 // newflag = s->secretflag[ft];
41872 screen_combo_modify_postroutine(s,q);
41873 }
41874 }
41875 //Inherent flags
41876 else
41877 {
41878 if ( combobuf[s->data[q]].flag == ID ) {
41879 screen_combo_modify_preroutine(s,q);
41880 s->data[q] = s->secretcombo[ft];
41881 s->cset[q] = s->secretcset[ft];
41882 //s->sflag[q] = s->secretflag[ft];
41883 screen_combo_modify_postroutine(s,q);
41884 }
41885
41886 }
41887 }
41888 }
41889 }
41890
41891 }
41892 //NPCData
41893
41894 //NPCData Getter Macros
41895
41896
41897
41898
41899 //NPCData-> Function
41900 #define GET_NPCDATA_FUNCTION_VAR_INT(member) \
41901 { \
41902 int32_t ID = get_register(sarg2) / 10000; \
41903 if(ID < 1 || ID > (MAXGUYS-1)) \
41904 set_register(sarg1, -10000); \
41905 else \
41906 set_register(sarg1, guysbuf[ID].member * 10000); \
41907 }
41908
41909 #define GET_NPCDATA_FUNCTION_VAR_INDEX(member, indexbound) \
41910 { \
41911 int32_t ID = int32_t(ri->d[rINDEX] / 10000);\
41912 int32_t indx = vbound((ri->d[rINDEX2] / 10000), 0, indexbound); \
41913 if(ID < 1 || ID > (MAXGUYS-1)) \
41914 set_register(sarg1, -10000); \
41915 else \
41916 set_register(sarg1, guysbuf[ID].member[indx] * 10000); \
41917 }
41918
41919 #define GET_NPCDATA_FUNCTION_VAR_FLAG(member) \
41920 { \
41921 int32_t ID = int32_t(ri->d[rINDEX] / 10000);\
41922 int32_t flag = int32_t(ri->d[rINDEX2] / 10000);\
41923 if(ID < 1 || ID > (MAXGUYS-1)) \
41924 set_register(sarg1, -10000); \
41925 else \
41926 set_register(sarg1, (guysbuf[ID].member&flag) ? 10000 : 0); \
41927 }
41928
41929 void FFScript::getNPCData_tile(){ GET_NPCDATA_FUNCTION_VAR_INT(tile); } //word
41930 void FFScript::getNPCData_e_height(){ GET_NPCDATA_FUNCTION_VAR_INT(e_height); }
41931 void FFScript::getNPCData_flags(){ GET_NPCDATA_FUNCTION_VAR_INT(flags); } //word
41932 void FFScript::getNPCData_flags2(){ GET_NPCDATA_FUNCTION_VAR_INT(flags2); }
41933 void FFScript::getNPCData_width(){ GET_NPCDATA_FUNCTION_VAR_INT(width); }
41934 void FFScript::getNPCData_height(){ GET_NPCDATA_FUNCTION_VAR_INT(height); }
41935 void FFScript::getNPCData_s_tile(){ GET_NPCDATA_FUNCTION_VAR_INT(s_tile); }
41936 void FFScript::getNPCData_s_width(){ GET_NPCDATA_FUNCTION_VAR_INT(s_width); }
41937 void FFScript::getNPCData_s_height(){ GET_NPCDATA_FUNCTION_VAR_INT(s_height); }
41938 void FFScript::getNPCData_e_tile(){ GET_NPCDATA_FUNCTION_VAR_INT(e_tile); }
41939 void FFScript::getNPCData_e_width(){ GET_NPCDATA_FUNCTION_VAR_INT(e_width); }
41940 void FFScript::getNPCData_hp(){ GET_NPCDATA_FUNCTION_VAR_INT(hp); }
41941 void FFScript::getNPCData_family(){ GET_NPCDATA_FUNCTION_VAR_INT(family); }
41942 void FFScript::getNPCData_cset(){ GET_NPCDATA_FUNCTION_VAR_INT(cset); }
41943 void FFScript::getNPCData_anim(){ GET_NPCDATA_FUNCTION_VAR_INT(anim); }
41944 void FFScript::getNPCData_e_anim(){ GET_NPCDATA_FUNCTION_VAR_INT(e_anim); }
41945 void FFScript::getNPCData_frate(){ GET_NPCDATA_FUNCTION_VAR_INT(frate); }
41946 void FFScript::getNPCData_e_frate(){ GET_NPCDATA_FUNCTION_VAR_INT(e_frate); }
41947 void FFScript::getNPCData_dp(){ GET_NPCDATA_FUNCTION_VAR_INT(dp); }
41948 void FFScript::getNPCData_wdp(){ GET_NPCDATA_FUNCTION_VAR_INT(wdp); }
41949 void FFScript::getNPCData_weapon(){ GET_NPCDATA_FUNCTION_VAR_INT(weapon); }
41950 void FFScript::getNPCData_rate(){ GET_NPCDATA_FUNCTION_VAR_INT(rate); }
41951 void FFScript::getNPCData_hrate(){ GET_NPCDATA_FUNCTION_VAR_INT(hrate); }
41952 void FFScript::getNPCData_step(){ GET_NPCDATA_FUNCTION_VAR_INT(step); }
41953 void FFScript::getNPCData_homing(){ GET_NPCDATA_FUNCTION_VAR_INT(homing); }
41954 void FFScript::getNPCData_grumble(){ GET_NPCDATA_FUNCTION_VAR_INT(grumble); }
41955 void FFScript::getNPCData_item_set(){ GET_NPCDATA_FUNCTION_VAR_INT(item_set); }
41956 void FFScript::getNPCData_bgsfx(){ GET_NPCDATA_FUNCTION_VAR_INT(bgsfx); }
41957 void FFScript::getNPCData_hitsfx(){ GET_NPCDATA_FUNCTION_VAR_INT(hitsfx); }
41958 void FFScript::getNPCData_deadsfx(){ GET_NPCDATA_FUNCTION_VAR_INT(deadsfx); }
41959 void FFScript::getNPCData_xofs(){ GET_NPCDATA_FUNCTION_VAR_INT(xofs); }
41960 void FFScript::getNPCData_yofs(){ GET_NPCDATA_FUNCTION_VAR_INT(yofs); }
41961 void FFScript::getNPCData_zofs(){ GET_NPCDATA_FUNCTION_VAR_INT(zofs); }
41962 void FFScript::getNPCData_hxofs(){ GET_NPCDATA_FUNCTION_VAR_INT(hxofs); }
41963 void FFScript::getNPCData_hyofs(){ GET_NPCDATA_FUNCTION_VAR_INT(hyofs); }
41964 void FFScript::getNPCData_hxsz(){ GET_NPCDATA_FUNCTION_VAR_INT(hxsz); }
41965 void FFScript::getNPCData_hysz(){ GET_NPCDATA_FUNCTION_VAR_INT(hysz); }
41966 void FFScript::getNPCData_hzsz(){ GET_NPCDATA_FUNCTION_VAR_INT(hzsz); }
41967 void FFScript::getNPCData_txsz(){ GET_NPCDATA_FUNCTION_VAR_INT(txsz); }
41968 void FFScript::getNPCData_tysz(){ GET_NPCDATA_FUNCTION_VAR_INT(tysz); }
41969 void FFScript::getNPCData_wpnsprite(){ GET_NPCDATA_FUNCTION_VAR_INT(wpnsprite); }
41970
41971 //NPCData Getters, two inputs, one return, similar to ISSolid
41972
41973 /*
41974
41975 void do_issolid()
41976 {
41977 int32_t x = int32_t(ri->d[rINDEX] / 10000);
41978 int32_t y = int32_t(ri->d[rINDEX2] / 10000);
41979
41980 set_register(sarg1, (_walkflag(x, y, 1) ? 10000 : 0));
41981 }
41982
41983 */
41984
41985
41986
41987
41988
41989
41990 //void FFScript::getNPCData_scriptdefence(){GET_NPCDATA_FUNCTION_VAR_INDEX(scriptdefence)};
41991
41992
41993 void FFScript::getNPCData_defense(){GET_NPCDATA_FUNCTION_VAR_INDEX(defense,int32_t(edefLAST255))};
41994
41995
41996 void FFScript::getNPCData_SIZEflags(){GET_NPCDATA_FUNCTION_VAR_FLAG(SIZEflags);}
41997
41998
41999 void FFScript::getNPCData_misc()
42000 {
42001 int32_t ID = int32_t(ri->d[rINDEX] / 10000); //the enemy ID value
42002 int32_t indx = int32_t(ri->d[rINDEX2] / 10000); //the misc index ID
42003 if ((ID < 1 || ID > 511) || ( indx < 0 || indx > 15 ))
42004 set_register(sarg1, -10000);
42005 switch ( indx )
42006 {
42007 case 0: set_register(sarg1, guysbuf[ID].misc1 * 10000); break;
42008 case 1: set_register(sarg1, guysbuf[ID].misc2 * 10000); break;
42009 case 2: set_register(sarg1, guysbuf[ID].misc3 * 10000); break;
42010 case 3: set_register(sarg1, guysbuf[ID].misc4 * 10000); break;
42011 case 4: set_register(sarg1, guysbuf[ID].misc5 * 10000); break;
42012 case 5: set_register(sarg1, guysbuf[ID].misc6 * 10000); break;
42013 case 6: set_register(sarg1, guysbuf[ID].misc7 * 10000); break;
42014 case 7: set_register(sarg1, guysbuf[ID].misc8 * 10000); break;
42015 case 8: set_register(sarg1, guysbuf[ID].misc9 * 10000); break;
42016 case 9: set_register(sarg1, guysbuf[ID].misc10 * 10000); break;
42017 case 10: set_register(sarg1, guysbuf[ID].misc11 * 10000); break;
42018 case 11: set_register(sarg1, guysbuf[ID].misc12 * 10000); break;
42019 case 12: set_register(sarg1, guysbuf[ID].misc13 * 10000); break;
42020 case 13: set_register(sarg1, guysbuf[ID].misc14 * 10000); break;
42021 case 14: set_register(sarg1, guysbuf[ID].misc15 * 10000); break;
42022 default: set_register(sarg1, -10000); break;
42023 }
42024 }
42025
42026 //NPCData Setters, two inputs, no return; similar to void GetDMapIntro(int32_t DMap, int32_t buffer[]);
42027
42028 /*
42029
42030 void do_getdmapintro(const bool v)
42031 {
42032 int32_t ID = SH::get_arg(sarg1, v) / 10000;
42033 int32_t arrayptr = get_register(sarg2) / 10000;
42034
42035 if(BC::checkDMapID(ID, "Game->GetDMapIntro") != SH::_NoError)
42036 return;
42037
42038 if(ArrayH::setArray(arrayptr, string(DMaps[ID].intro)) == SH::_Overflow)
42039 Z_scripterrlog("Array supplied to 'Game->GetDMapIntro' not large enough\n");
42040 }
42041
42042 */
42043
42044 //NPCData Setter Macros
42045
42046 //Variables for spritedata sp->member
42047
42048
42049
42050 //Functions for NPCData->
42051
42052 #define SET_NPCDATA_FUNCTION_VAR_INT(member, bound) \
42053 { \
42054 int32_t ID = get_register(sarg1) / 10000; \
42055 int32_t val = get_register(sarg2) / 10000; \
42056 if(ID < 1 || ID > (MAXGUYS-1)) \
42057 set_register(sarg1, -10000); \
42058 else \
42059 guysbuf[ID].member = vbound(val,0,bound); \
42060 }
42061
42062
42063
42064 #define SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(member) \
42065 { \
42066 int32_t ID = get_register(sarg1) / 10000; \
42067 int32_t val = get_register(sarg2) / 10000; \
42068 if(ID < 1 || ID > (MAXGUYS-1)) \
42069 set_register(sarg1, -10000); \
42070 else \
42071 guysbuf[ID].member = val; \
42072 }
42073
42074
42075 //SET_NPC_VAR_INDEX(member,value)
42076 #define SET_NPCDATA_FUNCTION_VAR_INDEX(member, val, bound, indexbound) \
42077 { \
42078 int32_t ID = (ri->d[rINDEX]/10000); \
42079 int32_t indx = vbound((ri->d[rINDEX2]/10000),0,indexbound); \
42080 if(ID < 1 || ID > (MAXGUYS-1)) \
42081 return; \
42082 else \
42083 guysbuf[ID].member[indx] = vbound(val,0,bound); \
42084 }
42085
42086 //Special case for flags, three inputs one return
42087 #define SET_NPCDATA_FUNCTION_VAR_FLAG(member, val) \
42088 { \
42089 int32_t ID = (ri->d[rINDEX]/10000); \
42090 int32_t flag = (ri->d[rINDEX2]/10000); \
42091 if(ID < 1 || ID > (MAXGUYS-1)) \
42092 return; \
42093 else \
42094 { \
42095 if ( val != 0 ) guysbuf[ID].member|=flag; \
42096 else guysbuf[ID].member|= ~flag; \
42097 }\
42098 }
42099
42100 void FFScript::setNPCData_flags(){SET_NPCDATA_FUNCTION_VAR_INT(flags,ZS_DWORD);} //word
42101 void FFScript::setNPCData_flags2(){SET_NPCDATA_FUNCTION_VAR_INT(flags2,ZS_DWORD);}
42102 void FFScript::setNPCData_width(){SET_NPCDATA_FUNCTION_VAR_INT(width,ZS_BYTE);}
42103 void FFScript::setNPCData_tile(){SET_NPCDATA_FUNCTION_VAR_INT(tile,ZS_WORD);}
42104 void FFScript::setNPCData_e_height(){SET_NPCDATA_FUNCTION_VAR_INT(e_height,ZS_BYTE);}
42105 void FFScript::setNPCData_height(){SET_NPCDATA_FUNCTION_VAR_INT(height,ZS_BYTE);}
42106 void FFScript::setNPCData_s_tile(){SET_NPCDATA_FUNCTION_VAR_INT(s_tile,ZS_WORD);}
42107 void FFScript::setNPCData_s_width(){SET_NPCDATA_FUNCTION_VAR_INT(s_width,ZS_BYTE);}
42108 void FFScript::setNPCData_s_height(){SET_NPCDATA_FUNCTION_VAR_INT(s_height,ZS_BYTE);}
42109 void FFScript::setNPCData_e_tile(){SET_NPCDATA_FUNCTION_VAR_INT(e_tile,ZS_WORD);}
42110 void FFScript::setNPCData_e_width(){SET_NPCDATA_FUNCTION_VAR_INT(e_width,ZS_BYTE);}
42111 void FFScript::setNPCData_hp(){SET_NPCDATA_FUNCTION_VAR_INT(hp,ZS_SHORT);}
42112 void FFScript::setNPCData_family(){SET_NPCDATA_FUNCTION_VAR_INT(family,ZS_SHORT);}
42113 void FFScript::setNPCData_cset(){SET_NPCDATA_FUNCTION_VAR_INT(cset,ZS_SHORT);}
42114 void FFScript::setNPCData_anim(){SET_NPCDATA_FUNCTION_VAR_INT(anim,ZS_SHORT);}
42115 void FFScript::setNPCData_e_anim(){SET_NPCDATA_FUNCTION_VAR_INT(e_anim,ZS_SHORT);}
42116 void FFScript::setNPCData_frate(){SET_NPCDATA_FUNCTION_VAR_INT(frate,ZS_SHORT);}
42117 void FFScript::setNPCData_e_frate(){SET_NPCDATA_FUNCTION_VAR_INT(e_frate,ZS_SHORT);}
42118 void FFScript::setNPCData_dp(){SET_NPCDATA_FUNCTION_VAR_INT(dp,ZS_SHORT);}
42119 void FFScript::setNPCData_wdp(){SET_NPCDATA_FUNCTION_VAR_INT(wdp,ZS_SHORT);}
42120 void FFScript::setNPCData_weapon(){SET_NPCDATA_FUNCTION_VAR_INT(weapon,ZS_SHORT);}
42121 void FFScript::setNPCData_rate(){SET_NPCDATA_FUNCTION_VAR_INT(rate,ZS_SHORT);}
42122 void FFScript::setNPCData_hrate(){SET_NPCDATA_FUNCTION_VAR_INT(hrate,ZS_SHORT);}
42123 void FFScript::setNPCData_step(){SET_NPCDATA_FUNCTION_VAR_INT(step,ZS_SHORT);}
42124 void FFScript::setNPCData_homing(){SET_NPCDATA_FUNCTION_VAR_INT(homing,ZS_SHORT);}
42125 void FFScript::setNPCData_grumble(){SET_NPCDATA_FUNCTION_VAR_INT(grumble,ZS_SHORT);}
42126 void FFScript::setNPCData_item_set(){SET_NPCDATA_FUNCTION_VAR_INT(item_set,ZS_SHORT);}
42127 void FFScript::setNPCData_bgsfx(){SET_NPCDATA_FUNCTION_VAR_INT(bgsfx,ZS_SHORT);}
42128 void FFScript::setNPCData_hitsfx(){SET_NPCDATA_FUNCTION_VAR_INT(hitsfx,ZS_BYTE);}
42129 void FFScript::setNPCData_deadsfx(){SET_NPCDATA_FUNCTION_VAR_INT(deadsfx,ZS_BYTE);}
42130 void FFScript::setNPCData_xofs(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(xofs);}
42131 void FFScript::setNPCData_yofs(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(yofs);}
42132 void FFScript::setNPCData_zofs(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(zofs);}
42133 void FFScript::setNPCData_hxofs(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(hxofs);}
42134 void FFScript::setNPCData_hyofs(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(hyofs);}
42135 void FFScript::setNPCData_hxsz(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(hxsz);}
42136 void FFScript::setNPCData_hysz(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(hysz);}
42137 void FFScript::setNPCData_hzsz(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(hzsz);}
42138 void FFScript::setNPCData_txsz(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(txsz);}
42139 void FFScript::setNPCData_tysz(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(tysz);}
42140 void FFScript::setNPCData_wpnsprite(){SET_NPCDATA_FUNCTION_VAR_INT(wpnsprite,511);}
42141
42142 //NPCData Setters, three inputs, no return. works as SetDMapScreenD function
42143
42144
42145
42146
42147
42148
42149
42150 //void FFScript::setNPCData_scriptdefence(){SET_NPCDATA_FUNCTION_VAR_INDEX(scriptdefence);}
42151 void FFScript::setNPCData_defense(int32_t v){SET_NPCDATA_FUNCTION_VAR_INDEX(defense,v, ZS_INT, int32_t(edefLAST255) );}
42152 void FFScript::setNPCData_SIZEflags(int32_t v){SET_NPCDATA_FUNCTION_VAR_FLAG(SIZEflags,v);}
42153 void FFScript::setNPCData_misc(int32_t val)
42154 {
42155 int32_t ID = int32_t(ri->d[rINDEX] / 10000); //the enemy ID value
42156 int32_t indx = int32_t(ri->d[rINDEX2] / 10000); //the misc index ID
42157 if ((ID < 1 || ID > 511) || ( indx < 0 || indx > 15 )) return;
42158 switch ( indx )
42159 {
42160 case 0: guysbuf[ID].misc1 = val; break;
42161 case 1: guysbuf[ID].misc2 = val; break;
42162 case 2: guysbuf[ID].misc3 = val; break;
42163 case 3: guysbuf[ID].misc4 = val; break;
42164 case 4: guysbuf[ID].misc5 = val; break;
42165 case 5: guysbuf[ID].misc6 = val; break;
42166 case 6: guysbuf[ID].misc7 = val; break;
42167 case 7: guysbuf[ID].misc8 = val; break;
42168 case 8: guysbuf[ID].misc9 = val; break;
42169 case 9: guysbuf[ID].misc10 = val; break;
42170 case 10: guysbuf[ID].misc11 = val; break;
42171 case 11: guysbuf[ID].misc12 = val; break;
42172 case 12: guysbuf[ID].misc13 = val; break;
42173 case 13: guysbuf[ID].misc14 = val; break;
42174 case 14: guysbuf[ID].misc15 = val; break;
42175 default: break;
42176 }
42177
42178 };
42179
42180 //ComboData
42181
42182 //Macros
42183
42184 //Are these right? newcombo is *combo_class_buf and the others are *combobuf
42185
42186 //Getters for ComboData 'Type' submembers.
42187 #define GET_COMBODATA_TYPE_INT(member) \
42188 { \
42189 int32_t ID = vbound((get_register(sarg2) / 10000),0,MAXCOMBOS);\
42190 set_register(sarg1, combo_class_buf[combobuf[ID].type].member * 10000); \
42191 }
42192
42193 //this may need additional macros.
42194 //for combo_class_buf[ID].member ?
42195 //I'm not sure which it needs to be at present.
42196
42197 #define GET_COMBODATA_TYPE_INDEX(member, bound) \
42198 { \
42199 int32_t ID = int32_t(vbound((ri->d[rINDEX] / 10000),0,MAXCOMBOS));\
42200 int32_t indx = int32_t(vbound((ri->d[rINDEX2] / 10000), 0, bound));\
42201 set_register(sarg1, combo_class_buf[combobuf[ID].type].member[indx] * 10000); \
42202 }
42203
42204 #define GET_COMBODATA_TYPE_FLAG(member) \
42205 { \
42206 int32_t ID = int32_t(vbound(ri->d[rINDEX] / 10000),0,MAXCOMBOS);\
42207 int32_t flag = int32_t(ri->d[rINDEX2] / 10000);\
42208 set_register(sarg1, (combo_class_buf[combobuf[ID].type].member&flag) ? 10000 : 0); \
42209 }
42210
42211
42212
42213 //Getters for ComboData main members.
42214 #define GET_COMBODATA_VAR_INT(member) \
42215 { \
42216 int32_t ID = vbound( (get_register(sarg2) / 10000), 0, MAXCOMBOS);\
42217 set_register(sarg1, combobuf[ID].member * 10000); \
42218 }
42219
42220 #define GET_COMBODATA_VAR_INDEX(member, bound) \
42221 { \
42222 int32_t ID = int32_t( vbound( (ri->d[rINDEX] / 10000),0,MAXCOMBOS) );\
42223 int32_t indx = int32_t ( vbound( (ri->d[rINDEX2] / 10000),0,bound) );\
42224 set_register(sarg1, combobuf[ID].member[indx] * 10000); \
42225 }
42226
42227 #define GET_COMBODATA_VAR_FLAG(member) \
42228 { \
42229 int32_t ID = int32_t( vbound( ( ri->d[rINDEX] / 10000),0,MAXCOMBOS) );\
42230 int32_t flag = int32_t(ri->d[rINDEX2] / 10000);\
42231 set_register(sarg1, (combobuf[ID].member&flag) ? 10000 : 0); \
42232 }
42233
42234
42235
42236 //ComboData Setter Macros
42237
42238 //Setters for ComboData 'type' submembers.
42239 #define SET_COMBODATA_TYPE_INT(member, bound) \
42240 { \
42241 int32_t ID = get_register(sarg1) / 10000; \
42242 int32_t val = vbound( (get_register(sarg2) / 10000), 0, bound); \
42243 if(ID < 1 || ID > 511) \
42244 set_register(sarg1, -10000); \
42245 else \
42246 combo_class_buf[combobuf[ID].type].member = val; \
42247 }
42248
42249 #define SET_COMBODATA_TYPE_INDEX(member, val, bound, indexbound) \
42250 { \
42251 int32_t ID = vbound((ri->d[rINDEX]/10000),0,MAXCOMBOS); \
42252 int32_t indx = vbound((ri->d[rINDEX2]/10000),0,indexbound); \
42253 combo_class_buf[combobuf[ID].type].member[indx] = vbound(val,0,bound); \
42254 }
42255
42256 #define SET_COMBODATA_TYPE_FLAG(member, val, bound) \
42257 { \
42258 int32_t ID = vbound((ri->d[rINDEX]/10000),0,MAXCOMBOS); \
42259 int32_t flag = (ri->d[rINDEX2]/10000); \
42260 combo_class_buf[combobuf[ID].type].member&flag = ((vbound(val,0,bound))!=0); \
42261 \
42262
42263
42264 //Setters for ComboData main members
42265 #define SET_COMBODATA_VAR_INT(member, bound) \
42266 { \
42267 int32_t ID = vbound( (get_register(sarg1) / 10000), 0, MAXCOMBOS); \
42268 int32_t val = vbound((get_register(sarg2) / 10000),0,bound); \
42269 combobuf[ID].member = val; \
42270 }
42271
42272 //SET_NPC_VAR_INDEX(member,value)
42273 #define SET_COMBODATA_VAR_INDEX(member, val, bound, indexbound) \
42274 { \
42275 int32_t ID = vbound((ri->d[rINDEX]/10000),0,MAXCOMBOS); \
42276 int32_t indx = vbound((ri->d[rINDEX2]/10000),0,indexbound); \
42277 combobuf[ID].member[indx] = vbound(val,0,bound); \
42278 }
42279
42280 //Special case for flags, three inputs one return
42281 #define SET_COMBODATA_VAR_FLAG(member, val, bound) \
42282 { \
42283 int32_t ID = vbound((ri->d[rINDEX]/10000),0,MAXCOMBOS); \
42284 int32_t flag = (ri->d[rINDEX2]/10000); \
42285 else \
42286 { \
42287 combobuf[ID].member&flag = ((bvound(val,0,bound))!=0); \
42288 }\
42289 }
42290
42291 //Getters
42292
42293 //one input, one return
42294 void FFScript::getComboData_block_enemies(){ GET_COMBODATA_TYPE_INT(block_enemies); } //byte a
42295 void FFScript::getComboData_block_hole(){ GET_COMBODATA_TYPE_INT(block_hole); } //byte b
42296 void FFScript::getComboData_block_trigger(){ GET_COMBODATA_TYPE_INT(block_trigger); } //byte c
42297 void FFScript::getComboData_conveyor_x_speed(){ GET_COMBODATA_TYPE_INT(conveyor_x_speed); } //int16_t e
42298 void FFScript::getComboData_conveyor_y_speed(){ GET_COMBODATA_TYPE_INT(conveyor_y_speed); } //int16_t f
42299 void FFScript::getComboData_create_enemy(){ GET_COMBODATA_TYPE_INT(create_enemy); } //word g
42300 void FFScript::getComboData_create_enemy_when(){ GET_COMBODATA_TYPE_INT(create_enemy_when); } //byte h
42301 void FFScript::getComboData_create_enemy_change(){ GET_COMBODATA_TYPE_INT(create_enemy_change); } //int32_t i
42302 void FFScript::getComboData_directional_change_type(){ GET_COMBODATA_TYPE_INT(directional_change_type); } //byte j
42303 void FFScript::getComboData_distance_change_tiles(){ GET_COMBODATA_TYPE_INT(distance_change_tiles); } //int32_t k
42304 void FFScript::getComboData_dive_item(){ GET_COMBODATA_TYPE_INT(dive_item); } //int16_t l
42305 void FFScript::getComboData_dock(){ GET_COMBODATA_TYPE_INT(dock); } //byte m
42306 void FFScript::getComboData_fairy(){ GET_COMBODATA_TYPE_INT(fairy); } //byte n
42307 void FFScript::getComboData_ff_combo_attr_change(){ GET_COMBODATA_TYPE_INT(ff_combo_attr_change); } //byte o
42308 void FFScript::getComboData_foot_decorations_tile(){ GET_COMBODATA_TYPE_INT(foot_decorations_tile); } //int32_t p
42309 void FFScript::getComboData_foot_decorations_type(){ GET_COMBODATA_TYPE_INT(foot_decorations_type); } //byte q
42310 void FFScript::getComboData_hookshot_grab_point(){ GET_COMBODATA_TYPE_INT(hookshot_grab_point); } //byte r
42311 void FFScript::getComboData_ladder_pass(){ GET_COMBODATA_TYPE_INT(ladder_pass); } //byte s
42312 void FFScript::getComboData_lock_block_type(){ GET_COMBODATA_TYPE_INT(lock_block_type); } //byte t
42313 void FFScript::getComboData_lock_block_change(){ GET_COMBODATA_TYPE_INT(lock_block_change); } //int32_t u
42314 void FFScript::getComboData_magic_mirror_type(){ GET_COMBODATA_TYPE_INT(magic_mirror_type); } //byte v
42315 void FFScript::getComboData_modify_hp_amount(){ GET_COMBODATA_TYPE_INT(modify_hp_amount); } //int16_t w
42316 void FFScript::getComboData_modify_hp_delay(){ GET_COMBODATA_TYPE_INT(modify_hp_delay); } //byte x
42317 void FFScript::getComboData_modify_hp_type(){ GET_COMBODATA_TYPE_INT(modify_hp_type); } //byte y
42318 void FFScript::getComboData_modify_mp_amount(){ GET_COMBODATA_TYPE_INT(modify_mp_amount); } //int16_t z
42319 void FFScript::getComboData_modify_mp_delay(){ GET_COMBODATA_TYPE_INT(modify_mp_delay); } //byte aa
42320 void FFScript::getComboData_modify_mp_type(){ GET_COMBODATA_TYPE_INT(modify_mp_type); } //byte ab
42321 void FFScript::getComboData_no_push_blocks(){ GET_COMBODATA_TYPE_INT(no_push_blocks); } //byte ac
42322 void FFScript::getComboData_overhead(){ GET_COMBODATA_TYPE_INT(overhead); } //byte ad
42323 void FFScript::getComboData_place_enemy(){ GET_COMBODATA_TYPE_INT(place_enemy); } //byte ae
42324 void FFScript::getComboData_push_direction(){ GET_COMBODATA_TYPE_INT(push_direction); } //byte af
42325 void FFScript::getComboData_push_weight(){ GET_COMBODATA_TYPE_INT(push_weight); } //byte ag heavy or not
42326 void FFScript::getComboData_push_wait(){ GET_COMBODATA_TYPE_INT(push_wait); } //byte ah
42327 void FFScript::getComboData_pushed(){ GET_COMBODATA_TYPE_INT(pushed); } //byte ai
42328 void FFScript::getComboData_raft(){ GET_COMBODATA_TYPE_INT(raft); } //byte aj
42329 void FFScript::getComboData_reset_room(){ GET_COMBODATA_TYPE_INT(reset_room); } //byte ak
42330 void FFScript::getComboData_save_point_type(){ GET_COMBODATA_TYPE_INT(save_point_type); } //byte al
42331 void FFScript::getComboData_screen_freeze_type(){ GET_COMBODATA_TYPE_INT(screen_freeze_type); } //byte am
42332
42333 void FFScript::getComboData_secret_combo(){ GET_COMBODATA_TYPE_INT(secret_combo); } //byte an
42334 void FFScript::getComboData_singular(){ GET_COMBODATA_TYPE_INT(singular); } //byte ao
42335 void FFScript::getComboData_slow_movement(){ GET_COMBODATA_TYPE_INT(slow_movement); } //byte ap
42336 void FFScript::getComboData_statue_type(){ GET_COMBODATA_TYPE_INT(statue_type); } //byte aq
42337 void FFScript::getComboData_step_type(){ GET_COMBODATA_TYPE_INT(step_type); } //byte ar
42338 void FFScript::getComboData_step_change_to(){ GET_COMBODATA_TYPE_INT(step_change_to); } //int32_t as
42339 void FFScript::getComboData_strike_remnants(){ GET_COMBODATA_TYPE_INT(strike_remnants); } //int32_t au
42340 void FFScript::getComboData_strike_remnants_type(){ GET_COMBODATA_TYPE_INT(strike_remnants_type); } //byte av
42341 void FFScript::getComboData_strike_change(){ GET_COMBODATA_TYPE_INT(strike_change); } //int32_t aw
42342 void FFScript::getComboData_strike_item(){ GET_COMBODATA_TYPE_INT(strike_item); } //int16_t ax
42343 void FFScript::getComboData_touch_item(){ GET_COMBODATA_TYPE_INT(touch_item); } //int16_t ay
42344 void FFScript::getComboData_touch_stairs(){ GET_COMBODATA_TYPE_INT(touch_stairs); } //byte az
42345 void FFScript::getComboData_trigger_type(){ GET_COMBODATA_TYPE_INT(trigger_type); } //byte ba
42346 void FFScript::getComboData_trigger_sensitive(){ GET_COMBODATA_TYPE_INT(trigger_sensitive); } //byte bb
42347 void FFScript::getComboData_warp_type(){ GET_COMBODATA_TYPE_INT(warp_type); } //byte bc
42348 void FFScript::getComboData_warp_sensitive(){ GET_COMBODATA_TYPE_INT(warp_sensitive); } //byte bd
42349 void FFScript::getComboData_warp_direct(){ GET_COMBODATA_TYPE_INT(warp_direct); } //byte be
42350 void FFScript::getComboData_warp_location(){ GET_COMBODATA_TYPE_INT(warp_location); } //byte bf
42351 void FFScript::getComboData_water(){ GET_COMBODATA_TYPE_INT(water); } //byte bg
42352 void FFScript::getComboData_whistle(){ GET_COMBODATA_TYPE_INT(whistle); } //byte bh
42353 void FFScript::getComboData_win_game(){ GET_COMBODATA_TYPE_INT(win_game); } //byte bi
42354 void FFScript::getComboData_block_weapon_lvl(){ GET_COMBODATA_TYPE_INT(block_weapon_lvl); } //byte bj - max level of weapon to block
42355
42356 void FFScript::getComboData_tile(){ GET_COMBODATA_VAR_INT(tile); } //newcombo, word
42357 void FFScript::getComboData_flip(){ GET_COMBODATA_VAR_INT(flip); } //newcombo byte
42358
42359 void FFScript::getComboData_walk(){ GET_COMBODATA_VAR_INT(walk); } //newcombo byte
42360 void FFScript::getComboData_type(){ GET_COMBODATA_VAR_INT(type); } //newcombo byte
42361 void FFScript::getComboData_csets(){ GET_COMBODATA_VAR_INT(csets); } //newcombo byte
42362 void FFScript::getComboData_frames(){ GET_COMBODATA_VAR_INT(frames); } //newcombo byte
42363 void FFScript::getComboData_speed(){ GET_COMBODATA_VAR_INT(speed); } //newcombo byte
42364 void FFScript::getComboData_nextcombo(){ GET_COMBODATA_VAR_INT(nextcombo); } //newcombo word
42365 void FFScript::getComboData_nextcset(){ GET_COMBODATA_VAR_INT(nextcset); } //newcombo byte
42366 void FFScript::getComboData_flag(){ GET_COMBODATA_VAR_INT(flag); } //newcombo byte
42367 void FFScript::getComboData_skipanim(){ GET_COMBODATA_VAR_INT(skipanim); } //newcombo byte
42368 void FFScript::getComboData_nexttimer(){ GET_COMBODATA_VAR_INT(nexttimer); } //newcombo word
42369 void FFScript::getComboData_skipanimy(){ GET_COMBODATA_VAR_INT(skipanimy); } //newcombo byte
42370 void FFScript::getComboData_animflags(){ GET_COMBODATA_VAR_INT(animflags); } //newcombo byte
42371
42372
42373 //two inputs, one return
42374 void FFScript::getComboData_block_weapon(){ GET_COMBODATA_TYPE_INDEX(block_weapon,32); } //byte array[32] d (ID of LWeapon)
42375 void FFScript::getComboData_expansion(){ GET_COMBODATA_VAR_INDEX(expansion,6); } //newcombo byte, arr[6]
42376 void FFScript::getComboData_strike_weapons(){ GET_COMBODATA_TYPE_INDEX(strike_weapons,32); } //byte at, arr[32]
42377
42378 //Setters, two inputs no returns
42379
42380 void FFScript::setComboData_block_enemies(){ SET_COMBODATA_TYPE_INT(block_enemies,ZS_BYTE); } //byte a
42381 void FFScript::setComboData_block_hole(){ SET_COMBODATA_TYPE_INT(block_hole,ZS_BYTE); } //byte b
42382 void FFScript::setComboData_block_trigger(){ SET_COMBODATA_TYPE_INT(block_trigger,ZS_BYTE); } //byte c
42383 void FFScript::setComboData_conveyor_x_speed(){ SET_COMBODATA_TYPE_INT(conveyor_x_speed,ZS_SHORT); } //int16_t e
42384 void FFScript::setComboData_conveyor_y_speed(){ SET_COMBODATA_TYPE_INT(conveyor_y_speed,ZS_SHORT); } //int16_t f
42385 void FFScript::setComboData_create_enemy(){ SET_COMBODATA_TYPE_INT(create_enemy,ZS_WORD); } //word g
42386 void FFScript::setComboData_create_enemy_when(){ SET_COMBODATA_TYPE_INT(create_enemy_when,ZS_BYTE); } //byte h
42387 void FFScript::setComboData_create_enemy_change(){ SET_COMBODATA_TYPE_INT(create_enemy_change,ZS_LONG); } //int32_t i
42388 void FFScript::setComboData_directional_change_type(){ SET_COMBODATA_TYPE_INT(directional_change_type,ZS_BYTE); } //byte j
42389 void FFScript::setComboData_distance_change_tiles(){ SET_COMBODATA_TYPE_INT(distance_change_tiles,ZS_LONG); } //int32_t k
42390 void FFScript::setComboData_dive_item(){ SET_COMBODATA_TYPE_INT(dive_item,ZS_SHORT); } //int16_t l
42391 void FFScript::setComboData_dock(){ SET_COMBODATA_TYPE_INT(dock,ZS_BYTE); } //byte m
42392 void FFScript::setComboData_fairy(){ SET_COMBODATA_TYPE_INT(fairy,ZS_BYTE); } //byte n
42393 void FFScript::setComboData_ff_combo_attr_change(){ SET_COMBODATA_TYPE_INT(ff_combo_attr_change,ZS_BYTE); } //byte o
42394 void FFScript::setComboData_foot_decorations_tile(){ SET_COMBODATA_TYPE_INT(foot_decorations_tile,ZS_LONG); } //int32_t p
42395 void FFScript::setComboData_foot_decorations_type(){ SET_COMBODATA_TYPE_INT(foot_decorations_type,ZS_BYTE); } //byte q
42396 void FFScript::setComboData_hookshot_grab_point(){ SET_COMBODATA_TYPE_INT(hookshot_grab_point,ZS_BYTE); } //byte r
42397 void FFScript::setComboData_ladder_pass(){ SET_COMBODATA_TYPE_INT(ladder_pass,ZS_BYTE); } //byte s
42398 void FFScript::setComboData_lock_block_type(){ SET_COMBODATA_TYPE_INT(lock_block_type,ZS_BYTE); } //byte t
42399 void FFScript::setComboData_lock_block_change(){ SET_COMBODATA_TYPE_INT(lock_block_change,ZS_LONG); } //int32_t u
42400 void FFScript::setComboData_magic_mirror_type(){ SET_COMBODATA_TYPE_INT(magic_mirror_type,ZS_BYTE); } //byte v
42401 void FFScript::setComboData_modify_hp_amount(){ SET_COMBODATA_TYPE_INT(modify_hp_amount,ZS_SHORT); } //int16_t w
42402 void FFScript::setComboData_modify_hp_delay(){ SET_COMBODATA_TYPE_INT(modify_hp_delay,ZS_BYTE); } //byte x
42403 void FFScript::setComboData_modify_hp_type(){ SET_COMBODATA_TYPE_INT(modify_hp_type,ZS_BYTE); } //byte y
42404 void FFScript::setComboData_modify_mp_amount(){ SET_COMBODATA_TYPE_INT(modify_mp_amount,ZS_SHORT); } //int16_t z
42405 void FFScript::setComboData_modify_mp_delay(){ SET_COMBODATA_TYPE_INT(modify_mp_delay,ZS_BYTE); } //byte aa
42406 void FFScript::setComboData_modify_mp_type(){ SET_COMBODATA_TYPE_INT(modify_mp_type,ZS_BYTE); } //byte ab
42407 void FFScript::setComboData_no_push_blocks(){ SET_COMBODATA_TYPE_INT(no_push_blocks,ZS_BYTE); } //byte ac
42408 void FFScript::setComboData_overhead(){ SET_COMBODATA_TYPE_INT(overhead,ZS_BYTE); } //byte ad
42409 void FFScript::setComboData_place_enemy(){ SET_COMBODATA_TYPE_INT(place_enemy,ZS_BYTE); } //byte ae
42410 void FFScript::setComboData_push_direction(){ SET_COMBODATA_TYPE_INT(push_direction,ZS_BYTE); } //byte af
42411 void FFScript::setComboData_push_weight(){ SET_COMBODATA_TYPE_INT(push_weight,ZS_BYTE); } //byte ag heavy or not
42412 void FFScript::setComboData_push_wait(){ SET_COMBODATA_TYPE_INT(push_wait,ZS_BYTE); } //byte ah
42413 void FFScript::setComboData_pushed(){ SET_COMBODATA_TYPE_INT(pushed,ZS_BYTE); } //byte ai
42414 void FFScript::setComboData_raft(){ SET_COMBODATA_TYPE_INT(raft,ZS_BYTE); } //byte aj
42415 void FFScript::setComboData_reset_room(){ SET_COMBODATA_TYPE_INT(reset_room,ZS_BYTE); } //byte ak
42416 void FFScript::setComboData_save_point_type(){ SET_COMBODATA_TYPE_INT(save_point_type,ZS_BYTE); } //byte al
42417 void FFScript::setComboData_screen_freeze_type(){ SET_COMBODATA_TYPE_INT(screen_freeze_type,ZS_BYTE); } //byte am
42418
42419 void FFScript::setComboData_secret_combo(){ SET_COMBODATA_TYPE_INT(secret_combo,ZS_BYTE); } //byte an
42420 void FFScript::setComboData_singular(){ SET_COMBODATA_TYPE_INT(singular,ZS_BYTE); } //byte ao
42421 void FFScript::setComboData_slow_movement(){ SET_COMBODATA_TYPE_INT(slow_movement,ZS_BYTE); } //byte ap
42422 void FFScript::setComboData_statue_type(){ SET_COMBODATA_TYPE_INT(statue_type,ZS_BYTE); } //byte aq
42423 void FFScript::setComboData_step_type(){ SET_COMBODATA_TYPE_INT(step_type,ZS_BYTE); } //byte ar
42424 void FFScript::setComboData_step_change_to(){ SET_COMBODATA_TYPE_INT(step_change_to,ZS_LONG); } //int32_t as
42425
42426 void FFScript::setComboData_strike_remnants(){ SET_COMBODATA_TYPE_INT(strike_remnants,ZS_LONG); } //int32_t au
42427 void FFScript::setComboData_strike_remnants_type(){ SET_COMBODATA_TYPE_INT(strike_remnants_type,ZS_BYTE); } //byte av
42428 void FFScript::setComboData_strike_change(){ SET_COMBODATA_TYPE_INT(strike_change,ZS_LONG); } //int32_t aw
42429 void FFScript::setComboData_strike_item(){ SET_COMBODATA_TYPE_INT(strike_item,ZS_SHORT); } //int16_t ax
42430 void FFScript::setComboData_touch_item(){ SET_COMBODATA_TYPE_INT(touch_item,ZS_SHORT); } //int16_t ay
42431 void FFScript::setComboData_touch_stairs(){ SET_COMBODATA_TYPE_INT(touch_stairs,ZS_BYTE); } //byte az
42432 void FFScript::setComboData_trigger_type(){ SET_COMBODATA_TYPE_INT(trigger_type,ZS_BYTE); } //byte ba
42433 void FFScript::setComboData_trigger_sensitive(){ SET_COMBODATA_TYPE_INT(trigger_sensitive,ZS_BYTE); } //byte bb
42434 void FFScript::setComboData_warp_type(){ SET_COMBODATA_TYPE_INT(warp_type,ZS_BYTE); } //byte bc
42435 void FFScript::setComboData_warp_sensitive(){ SET_COMBODATA_TYPE_INT(warp_sensitive,ZS_BYTE); } //byte bd
42436 void FFScript::setComboData_warp_direct(){ SET_COMBODATA_TYPE_INT(warp_direct,ZS_BYTE); } //byte be
42437 void FFScript::setComboData_warp_location(){ SET_COMBODATA_TYPE_INT(warp_location,ZS_BYTE); } //byte bf
42438 void FFScript::setComboData_water(){ SET_COMBODATA_TYPE_INT(water,ZS_BYTE); } //byte bg
42439 void FFScript::setComboData_whistle(){ SET_COMBODATA_TYPE_INT(whistle,ZS_BYTE); } //byte bh
42440 void FFScript::setComboData_win_game(){ SET_COMBODATA_TYPE_INT(win_game,ZS_BYTE); } //byte bi
42441 void FFScript::setComboData_block_weapon_lvl(){ SET_COMBODATA_TYPE_INT(block_weapon_lvl,ZS_BYTE); } //byte bj - max level of weapon to block
42442
42443 //combobuf
42444 void FFScript::setComboData_tile(){ SET_COMBODATA_VAR_INT(tile,ZS_WORD); } //newcombo, word
42445 void FFScript::setComboData_flip(){ SET_COMBODATA_VAR_INT(flip,ZS_BYTE); } //newcombo byte
42446
42447 void FFScript::setComboData_walk(){ SET_COMBODATA_VAR_INT(walk,ZS_BYTE); } //newcombo byte
42448 void FFScript::setComboData_type(){ SET_COMBODATA_VAR_INT(type,ZS_BYTE); } //newcombo byte
42449 void FFScript::setComboData_csets(){ SET_COMBODATA_VAR_INT(csets,ZS_BYTE); } //newcombo byte
42450 void FFScript::setComboData_frames(){ SET_COMBODATA_VAR_INT(frames,ZS_BYTE); } //newcombo byte
42451 void FFScript::setComboData_speed(){ SET_COMBODATA_VAR_INT(speed,ZS_BYTE); } //newcombo byte
42452 void FFScript::setComboData_nextcombo(){ SET_COMBODATA_VAR_INT(nextcombo,ZS_WORD); } //newcombo word
42453 void FFScript::setComboData_nextcset(){ SET_COMBODATA_VAR_INT(nextcset,ZS_BYTE); } //newcombo byte
42454 void FFScript::setComboData_flag(){ SET_COMBODATA_VAR_INT(flag,ZS_BYTE); } //newcombo byte
42455 void FFScript::setComboData_skipanim(){ SET_COMBODATA_VAR_INT(skipanim,ZS_BYTE); } //newcombo byte
42456 void FFScript::setComboData_nexttimer(){ SET_COMBODATA_VAR_INT(nexttimer,ZS_WORD); } //newcombo word
42457 void FFScript::setComboData_skipanimy(){ SET_COMBODATA_VAR_INT(skipanimy,ZS_BYTE); } //newcombo byte
42458 void FFScript::setComboData_animflags(){ SET_COMBODATA_VAR_INT(animflags,ZS_BYTE); } //newcombo byte
42459
42460 //three inputs, no returns
42461 void FFScript::setComboData_block_weapon(int32_t v){ SET_COMBODATA_TYPE_INDEX(block_weapon,v,ZS_BYTE,32); } //byte array[32] d (ID of LWeapon)
42462 void FFScript::setComboData_strike_weapons(int32_t v){ SET_COMBODATA_TYPE_INDEX(strike_weapons,v,ZS_BYTE,32); } //byte at, arr[32]
42463 void FFScript::setComboData_expansion(int32_t v){ SET_COMBODATA_VAR_INDEX(expansion,v,ZS_BYTE,6); } //newcombo byte, arr[6]
42464
42465 //SpriteData Macros
42466 #define GET_SPRITEDATA_TYPE_INT(member) \
42467 { \
42468 int32_t ID = vbound((get_register(sarg2) / 10000),0,255);\
42469 set_register(sarg1, wpnsbuf[ID].member * 10000); \
42470 }
42471
42472 #define SET_SPRITEDATA_TYPE_INT(member, bound) \
42473 { \
42474 int32_t ID = get_register(sarg1) / 10000; \
42475 int32_t val = vbound( (get_register(sarg2) / 10000), 0, bound); \
42476 if(ID < 1 || ID > 255) \
42477 set_register(sarg1, -10000); \
42478 else \
42479 wpnsbuf[ID].member = val; \
42480 }
42481
42482 #define SET_SPRITEDATA_TYPE_INT_NOBOUND(member) \
42483 { \
42484 int32_t ID = get_register(sarg1) / 10000; \
42485 int32_t val = get_register(sarg2) / 10000; \
42486 if(ID < 1 || ID > 255) \
42487 set_register(sarg1, -10000); \
42488 else \
42489 wpnsbuf[ID].member = val; \
42490 }
42491
42492
42493 void FFScript::getSpriteDataTile(){GET_SPRITEDATA_TYPE_INT(tile);}
42494 void FFScript::getSpriteDataMisc(){GET_SPRITEDATA_TYPE_INT(misc);}
42495 void FFScript::getSpriteDataCSets(){GET_SPRITEDATA_TYPE_INT(csets);}
42496 void FFScript::getSpriteDataFrames(){GET_SPRITEDATA_TYPE_INT(frames);}
42497 void FFScript::getSpriteDataSpeed(){GET_SPRITEDATA_TYPE_INT(speed);}
42498 void FFScript::getSpriteDataType(){GET_SPRITEDATA_TYPE_INT(type);}
42499 //void FFScript::getSpriteDataString();
42500
42501
42502
42503 void FFScript::setSpriteDataTile(){SET_SPRITEDATA_TYPE_INT(tile,ZS_WORD);}
42504 void FFScript::setSpriteDataMisc(){SET_SPRITEDATA_TYPE_INT(misc,ZS_CHAR);}
42505 void FFScript::setSpriteDataCSets(){SET_SPRITEDATA_TYPE_INT(csets,ZS_CHAR);}
42506 void FFScript::setSpriteDataFrames(){SET_SPRITEDATA_TYPE_INT(frames,ZS_CHAR);}
42507 void FFScript::setSpriteDataSpeed(){SET_SPRITEDATA_TYPE_INT(speed,ZS_CHAR);}
42508 void FFScript::setSpriteDataType(){SET_SPRITEDATA_TYPE_INT(type,ZS_CHAR);}
42509 //void FFScript::setSpriteDataString();
42510
42511
42512 void FFScript::do_setMIDI_volume(int32_t m)
42513 {
42514 master_volume(-1,(vbound(m,0,255)));
42515 }
42516 void FFScript::do_setMusic_volume(int32_t m)
42517 {
42518 emusic_volume = vbound(m,0,255);
42519 }
42520 void FFScript::do_setDIGI_volume(int32_t m)
42521 {
42522 master_volume((vbound(m,0,255)),-1);
42523 }
42524 void FFScript::do_setSFX_volume(int32_t m)
42525 {
42526 sfx_volume = m;
42527 }
42528 void FFScript::do_setSFX_pan(int32_t m)
42529 {
42530 pan_style = vbound(m,0,3);
42531 }
42532 int32_t FFScript::do_getMIDI_volume()
42533 {
42534 return ((int32_t)midi_volume);
42535 }
42536 int32_t FFScript::do_getMusic_volume()
42537 {
42538 return ((int32_t)emusic_volume);
42539 }
42540 int32_t FFScript::do_getDIGI_volume()
42541 {
42542 return ((int32_t)digi_volume);
42543 }
42544 int32_t FFScript::do_getSFX_volume()
42545 {
42546 return ((int32_t)sfx_volume);
42547 }
42548 int32_t FFScript::do_getSFX_pan()
42549 {
42550 return ((int32_t)pan_style);
42551 }
42552
42553
42554 //Change Game Over Screen Values
42555 void FFScript::FFSetSaveScreenSetting()
42556 {
42557
42558 int32_t indx = get_register(sarg1) / 10000;
42559 int32_t value = get_register(sarg2) / 10000; //bounded in zelda.cpp
42560 if(indx < 0 || indx > 11)
42561 set_register(sarg1, -10000);
42562 else
42563 SetSaveScreenSetting(indx, value);
42564 }
42565
42566
42567
42568 void FFScript::FFChangeSubscreenText()
42569 {
42570
42571 int32_t index = get_register(sarg1) / 10000;
42572 int32_t arrayptr = get_register(sarg2) / 10000;
42573
42574 if ( index < 0 || index > 3 )
42575 {
42576 al_trace("The index supplied to Game->SetSubscreenText() is invalid. The index specified was: %d /n", index);
42577 return;
42578 }
42579
42580 string filename_str;
42581
42582
42583
42584 ArrayH::getString(arrayptr, filename_str, 73);
42585 ChangeSubscreenText(index,filename_str.c_str());
42586
42587 //newtext[32]='\0';
42588
42589
42590
42591 }
42592
42593 void FFScript::do_typedpointer_typecast(const bool v)
42594 {
42595 int32_t ptr = SH::get_arg(sarg1, v);
42596 set_register(sarg1, ptr);
42597 }
42598
42599 1 void FFScript::SetItemMessagePlayed(int32_t itm)
42600 {
42601 1 game->item_messages_played[itm] = 1;
42602 1 }
42603 1 bool FFScript::GetItemMessagePlayed(int32_t itm)
42604 {
42605 1 return ((game->item_messages_played[itm] ) ? true : false);
42606 }
42607
42608 int32_t FFScript::getQRBit(int32_t rule)
42609 {
42610 return ( get_qr(rule) ? 1 : 0 );
42611 }
42612
42613 12311361 void FFScript::setHeroAction(int32_t a)
42614 {
42615 12311361 FF_hero_action = vbound(a, 0, 255);
42616 12311361 }
42617
42618 52066372 int32_t FFScript::getHeroAction()
42619 {
42620 52066372 int32_t special_action = Hero.getAction2();
42621
2/2
✓ Branch 0 taken 191669 times.
✓ Branch 1 taken 51874703 times.
52066372 if ( special_action != -1 ) return special_action; //spin, dive, charge
42622 51874703 else return FF_hero_action; //everything else
42623 52066372 }
42624 //get_bit
42625
42626 21031181 int32_t FFScript::GetScriptObjectUID(int32_t type)
42627 {
42628 21031181 ++script_UIDs[type];
42629 21031181 return script_UIDs[type];
42630 }
42631
42632 122 void FFScript::SetNegArray()
42633 {
42634 122 can_neg_array = !get_qr(qr_ZS_NO_NEG_ARRAY);
42635 122 }
42636
42637 409 void FFScript::init()
42638 {
42639 409 eventData.clear();
42640 409 countGenScripts();
42641 409 countObjects();
42642
2/2
✓ Branch 0 taken 4090 times.
✓ Branch 1 taken 409 times.
4499 for ( int32_t q = 0; q < wexLast; q++ ) warpex[q] = 0;
42643 409 print_ZASM = zasm_debugger;
42644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 409 times.
409 if ( zasm_debugger )
42645 {
42646 ZASMPrint(true);
42647 zasm_break_mode = ZASM_BREAK_HALT;
42648 }
42649
42650 409 temp_no_stepforward = 0;
42651 409 nostepforward = 0;
42652
42653 409 can_neg_array = !get_qr(qr_ZS_NO_NEG_ARRAY);
42654
42655 409 numscriptdraws = 0;
42656 409 skipscriptdraws = false;
42657 409 max_ff_rules = qr_MAX;
42658 409 coreflags = 0;
42659 409 skip_ending_credits = 0;
42660 409 music_update_cond = 0;
42661 409 music_update_flags = 0;
42662 //quest_format : is this properly initialised?
42663
2/2
✓ Branch 0 taken 27812 times.
✓ Branch 1 taken 409 times.
28221 for ( int32_t q = 0; q < susptLAST; q++ ) { system_suspend[q] = 0; }
42664
2/2
✓ Branch 0 taken 1227 times.
✓ Branch 1 taken 409 times.
1636 for ( int32_t q = 0; q < UID_TYPES; ++q ) { script_UIDs[q] = 0; }
42665 //for ( int32_t q = 0; q < 512; q++ ) FF_rules[q] = 0;
42666 409 FFCore.zasm_break_mode = ZASM_BREAK_NONE;
42667
42668 409 usr_midi_volume = midi_volume;
42669 409 usr_digi_volume = digi_volume;
42670 409 usr_sfx_volume = sfx_volume;
42671 409 usr_music_volume = emusic_volume;
42672
42673 409 usr_panstyle = pan_style;
42674 409 FF_hero_action = 0;
42675 409 enemy_removal_point[spriteremovalY1] = -32767;
42676 409 enemy_removal_point[spriteremovalY2] = 32767;
42677 409 enemy_removal_point[spriteremovalX1] = -32767;
42678 409 enemy_removal_point[spriteremovalX2] = 32767;
42679 409 enemy_removal_point[spriteremovalZ1] = -32767;
42680 409 enemy_removal_point[spriteremovalZ2] = 32767;
42681
42682 //Clear internal arrays for use by <std>, <ghost>, <tango>
42683
2/2
✓ Branch 0 taken 104704 times.
✓ Branch 1 taken 409 times.
105113 for ( int32_t q = 0; q < 256; ++q )
42684 {
42685 104704 StdArray[q] = 0;
42686 104704 GhostArray[q] = 0;
42687 104704 TangoArray[q] = 0;
42688 104704 }
42689
42690
2/2
✓ Branch 0 taken 1636 times.
✓ Branch 1 taken 409 times.
2045 for ( int32_t q = 0; q < 4; q++ )
42691 {
42692 1636 FF_screenbounds[q] = 0;
42693 1636 FF_screen_dimensions[q] = 0;
42694 1636 FF_subscreen_dimensions[q] = 0;
42695 1636 FF_eweapon_removal_bounds[q] = 0;
42696 1636 FF_lweapon_removal_bounds[q] = 0;
42697 1636 }
42698
2/2
✓ Branch 0 taken 4090 times.
✓ Branch 1 taken 409 times.
4499 for ( int32_t q = 0; q < FFSCRIPTCLASS_CLOCKS; q++ )
42699 {
42700 4090 FF_clocks[q] = 0;
42701 4090 }
42702
2/2
✓ Branch 0 taken 8180 times.
✓ Branch 1 taken 409 times.
8589 for ( int32_t q = 0; q < SCRIPT_DRAWING_RULES; q++ )
42703 {
42704 8180 ScriptDrawingRules[q] = 0;
42705 8180 }
42706
2/2
✓ Branch 0 taken 2454 times.
✓ Branch 1 taken 409 times.
2863 for ( int32_t q = 0; q < NUM_USER_MIDI_OVERRIDES; q++ )
42707 {
42708 2454 FF_UserMidis[q] = 0;
42709 2454 }
42710 409 subscreen_scroll_speed = 0; //make a define for a default and read quest override! -Z
42711 409 kb_typing_mode = false;
42712 409 initIncludePaths();
42713 409 initRunString();
42714 //clearRunningItemScripts();
42715 409 tempScreens[0] = tmpscr;
42716 409 ScrollingScreens[0] = tmpscr+1;
42717
2/2
✓ Branch 0 taken 2454 times.
✓ Branch 1 taken 409 times.
2863 for(int32_t q = 0; q < 6; ++q)
42718 {
42719 2454 tempScreens[q+1] = tmpscr2+q;
42720 2454 ScrollingScreens[q+1] = tmpscr3+q;
42721 2454 }
42722 409 ScrollingData[SCROLLDATA_DIR] = -1;
42723 409 ScrollingData[SCROLLDATA_NX] = 0;
42724 409 ScrollingData[SCROLLDATA_NY] = 0;
42725 409 ScrollingData[SCROLLDATA_OX] = 0;
42726 409 ScrollingData[SCROLLDATA_OY] = 0;
42727 409 user_rng_init();
42728 409 clear_script_engine_data();
42729
2/2
✓ Branch 0 taken 10158 times.
✓ Branch 1 taken 409 times.
10567 for (auto &it : jitted_scripts)
42730 {
42731 10158 jit_delete_script_handle(it.second);
42732 }
42733 409 jitted_scripts.clear();
42734 409 seen_scripts.clear();
42735 409 script_debug_handles.clear();
42736 409 runtime_script_debug_handle = nullptr;
42737 409 }
42738
42739 void FFScript::shutdown()
42740 {
42741 for (auto &it : jitted_scripts)
42742 {
42743 jit_delete_script_handle(it.second);
42744 }
42745 jitted_scripts.clear();
42746 }
42747
42748
42749 void FFScript::SetFFEngineFlag(int32_t flag, bool state)
42750 {
42751 if ( state ) { coreflags |= flag; }
42752 else coreflags &= ~flag;
42753 }
42754
42755 void FFScript::setSubscreenScrollSpeed(byte n)
42756 {
42757 subscreen_scroll_speed = n;
42758 }
42759
42760 int32_t FFScript::getSubscreenScrollSpeed()
42761 {
42762 return (int32_t)subscreen_scroll_speed;
42763 }
42764
42765 void FFScript::do_greyscale(const bool v)
42766 {
42767 bool on = (SH::get_arg(sarg1, v)) != 0;
42768 setMonochrome(on);
42769 }
42770
42771 void FFScript::do_monochromatic(const bool v)
42772 {
42773 int32_t colour = SH::get_arg(sarg1, v)/10000;
42774 setMonochromatic(colour);
42775 }
42776
42777 void FFScript::gfxmonohue()
42778 {
42779 int32_t _r = SH::read_stack(ri->sp + 3) / 10000;
42780 int32_t _g = SH::read_stack(ri->sp + 2) / 10000;
42781 int32_t _b = SH::read_stack(ri->sp + 1) / 10000;
42782 bool m = (SH::read_stack(ri->sp + 0) / 10000);
42783 doGFXMonohue(_r,_g,_b,m);
42784 }
42785
42786 void FFScript::clearTint()
42787 {
42788 doClearTint();
42789 }
42790
42791 void FFScript::Tint()
42792 {
42793 int32_t _r = SH::read_stack(ri->sp + 2) / 10000;
42794 int32_t _g = SH::read_stack(ri->sp + 1) / 10000;
42795 int32_t _b = SH::read_stack(ri->sp + 0) / 10000;
42796 doTint(_r,_g,_b);
42797 }
42798
42799 void FFScript::do_fx_zap(const bool v)
42800 {
42801 int32_t out = SH::get_arg(sarg1, v);
42802
42803 if ( out ) { FFScript::do_zapout(); }
42804 else FFScript::do_zapin();
42805 }
42806
42807 void FFScript::do_fx_wavy(const bool v)
42808 {
42809 int32_t out = SH::get_arg(sarg1, v);
42810
42811 if ( out ) { FFScript::do_wavyout(); }
42812 else FFScript::do_wavyin();
42813 }
42814
42815 162715495 int32_t FFScript::getQuestHeaderInfo(int32_t type)
42816 {
42817 162715495 return quest_format[type];
42818 }
42819
42820 string get_filestr(const bool relative) //Used for 'FileSystem' functions.
42821 {
42822 int32_t strptr = get_register(sarg1)/10000;
42823 string the_string;
42824 ArrayH::getString(strptr, the_string, 512);
42825 the_string = the_string.substr(the_string.find_first_not_of('/'),string::npos); //Kill leading '/'
42826 size_t last = the_string.find_last_not_of('/');
42827 if(last!=string::npos)++last;
42828 the_string = the_string.substr(0,last); //Kill trailing '/'
42829 if(relative)
42830 {
42831 char buf[2048+1] = {0};
42832 if(FFCore.get_scriptfile_path(buf, the_string.c_str()))
42833 the_string = buf;
42834 }
42835 return the_string;
42836 }
42837
42838 void FFScript::do_checkdir(const bool is_dir)
42839 {
42840 string the_string = get_filestr(get_qr(qr_BITMAP_AND_FILESYSTEM_PATHS_ALWAYS_RELATIVE));
42841 set_register(sarg1, checkPath(the_string.c_str(), is_dir) ? 10000 : 0);
42842 }
42843
42844 void FFScript::do_fs_remove()
42845 {
42846 string the_string = get_filestr(true);
42847 set_register(sarg1, remove(the_string.c_str()) ? 0 : 10000);
42848 }
42849
42850 16 void FFScript::Play_Level_Music()
42851 {
42852 16 int32_t m=tmpscr->screen_midi;
42853
42854
1/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 switch(m)
42855 {
42856 case -2:
42857 music_stop();
42858 break;
42859
42860 case -1:
42861 16 play_DmapMusic();
42862 16 break;
42863
42864 case 1:
42865 jukebox(ZC_MIDI_OVERWORLD);
42866 break;
42867
42868 case 2:
42869 jukebox(ZC_MIDI_DUNGEON);
42870 break;
42871
42872 case 3:
42873 jukebox(ZC_MIDI_LEVEL9);
42874 break;
42875
42876 default:
42877 if(m>=4 && m<4+MAXCUSTOMMIDIS)
42878 jukebox(m+MIDIOFFSET_MAPSCR);
42879 else
42880 music_stop();
42881 }
42882 16 }
42883
42884 16 void FFScript::do_warp_ex(bool v)
42885 {
42886 16 int32_t zscript_array_ptr = SH::get_arg(sarg1, v) / 10000;
42887 16 ArrayManager am(zscript_array_ptr);
42888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(am.invalid()) return;
42889 16 int32_t zscript_array_size = am.size();
42890
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
16 switch(zscript_array_size)
42891 {
42892 case 8:
42893 // {int32_t type, int32_t dmap, int32_t screen, int32_t x, int32_t y, int32_t effect, int32_t sound, int32_t flags}
42894 {
42895 if(DEVLOGGING) zprint("FFscript.cpp running do_warp_ex with %d args\n", 8);
42896 16 int32_t tmpwarp[8]={0};
42897
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 16 times.
144 for ( int32_t q = 0; q < wexDir; q++ )
42898 {
42899 128 tmpwarp[q] = (am.get(q)/10000);
42900 128 }
42901
42902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( ((unsigned)tmpwarp[1]) >= MAXDMAPS )
42903 {
42904 Z_scripterrlog("Invalid DMap ID (%d) passed to WarpEx(). Aborting.\n", tmpwarp[1]);
42905 return;
42906 }
42907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( ((unsigned)tmpwarp[2]) >= MAPSCRS )
42908 {
42909 Z_scripterrlog("Invalid Screen ID (%d) passed to WarpEx(). Aborting.\n", tmpwarp[2]);
42910 return;
42911 }
42912 //Extra sanity guard.
42913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( DMaps[tmpwarp[1]].map*MAPSCRS+DMaps[tmpwarp[1]].xoff+tmpwarp[2] >= (int32_t)TheMaps.size() )
42914 {
42915 Z_scripterrlog("Invalid destination passed to WarpEx(). Aborting.\n");
42916 return;
42917 }
42918 //If we passed the sanity checks, populate the FFCore array and begin the action!
42919
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 16 times.
144 for ( int32_t q = 0; q < wexDir; q++ )
42920 {
42921 128 FFCore.warpex[q] = tmpwarp[q];
42922 128 }
42923 16 FFCore.warpex[wexActive] = 1;
42924 16 FFCore.warpex[wexDir] = -1;
42925
42926 16 break;
42927 }
42928 case 9:
42929 // {int32_t type, int32_t dmap, int32_t screen, int32_t x, int32_t y, int32_t effect, int32_t sound, int32_t flags, int32_t dir}
42930 {
42931 if(DEVLOGGING) zprint("FFscript.cpp running do_warp_ex with %d args\n", 9);
42932 int32_t tmpwarp[9]={0};
42933
42934 for ( int32_t q = 0; q < wexActive; q++ )
42935 {
42936 tmpwarp[q] = (am.get(q)/10000);
42937 }
42938
42939 if ( ((unsigned)tmpwarp[1]) >= MAXDMAPS )
42940 {
42941 Z_scripterrlog("Invalid DMap ID (%d) passed to WarpEx(). Aborting.\n", tmpwarp[1]);
42942 return;
42943 }
42944 if ( ((unsigned)tmpwarp[2]) >= MAPSCRS )
42945 {
42946 Z_scripterrlog("Invalid Screen ID (%d) passed to WarpEx(). Aborting.\n", tmpwarp[2]);
42947 return;
42948 }
42949 //Extra sanity guard.
42950 if ( DMaps[tmpwarp[1]].map*MAPSCRS+DMaps[tmpwarp[1]].xoff+tmpwarp[2] >= (int32_t)TheMaps.size() )
42951 {
42952 Z_scripterrlog("Invalid destination passed to WarpEx(). Aborting.\n");
42953 return;
42954 }
42955 //If we passed the sanity checks, populate the FFCore array and begin the action!
42956 for ( int32_t q = 0; q < wexActive; q++ )
42957 {
42958 FFCore.warpex[q] = tmpwarp[q];
42959 }
42960 FFCore.warpex[wexActive] = 1;
42961
42962 for ( int32_t q = 0; q < wexActive; q++ )
42963 {
42964 FFCore.warpex[q] = tmpwarp[q];
42965 }
42966
42967 //for ( int32_t q = 0; q < wexLast; q++ )
42968 //{
42969 // zprint("FFCore.warpex[%d] is: %d\n", q, FFCore.warpex[q]);
42970 //}
42971
42972 break;
42973
42974 }
42975
42976 default:
42977 {
42978 Z_scripterrlog("Array supplied to Player->WarpEx() is the wrong size!\n The array size was: &d, and valid sizes are [8] and [9].\n",zscript_array_size);
42979 break;
42980 }
42981
42982
42983
42984 }
42985 16 }
42986
42987 ///////////////////////////////
42988 //* SCRIPT ENGINE FUNCTIONS *//
42989 ////////////////////////////////////////////////////////////////////////////
42990
42991 void FFScript::clearRunningItemScripts()
42992 {
42993 //for ( byte q = 0; q < 256; q++ ) runningItemScripts[q] = 0;
42994 }
42995
42996
42997 4997 void FFScript::warpScriptCheck()
42998 {
42999
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4996 times.
4997 if(get_qr(qr_SCRIPTDRAWSINWARPS))
43000 {
43001 1 FFCore.runWarpScripts(false);
43002 1 FFCore.runWarpScripts(true); //Waitdraw
43003 1 }
43004
3/4
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 4908 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 88 times.
4996 else if(get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN) && doscript(ScriptType::ScriptedPassiveSubscreen))
43005 {
43006
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(DMaps[currdmap].passive_sub_script != 0)
43007 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
43008
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
88 if (waitdraw(ScriptType::ScriptedPassiveSubscreen) && DMaps[currdmap].passive_sub_script != 0 && doscript(ScriptType::ScriptedPassiveSubscreen))
43009 {
43010 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
43011 waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
43012 }
43013 88 }
43014 4997 }
43015
43016 2 void FFScript::runWarpScripts(bool waitdraw)
43017 {
43018
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 if(waitdraw)
43019 {
43020
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if ((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME))
43021 {
43022 1 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
43023 1 FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME) = false;
43024 1 }
43025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
43026 {
43027 1 FFCore.itemScriptEngineOnWaitdraw();
43028 1 }
43029
2/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.waitdraw(ScriptType::Player) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
43030 {
43031 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
43032 FFCore.waitdraw(ScriptType::Player) = false;
43033 }
43034
2/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
43035 {
43036 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[currdmap].script,currdmap);
43037 FFCore.waitdraw(ScriptType::DMap) = false;
43038 }
43039
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
43040 {
43041 1 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script,currdmap);
43042 1 FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
43043 1 }
43044 //no doscript check here, becauseb of preload? Do we want to write doscript here? -Z 13th July, 2019
43045
2/10
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && FFCore.waitdraw(ScriptType::Screen) && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
43046 {
43047 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script);
43048 FFCore.waitdraw(ScriptType::Screen) = 0;
43049 }
43050 1 }
43051 else
43052 {
43053
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if ((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.doscript(ScriptType::Global, GLOBAL_SCRIPT_GAME))
43054 {
43055 1 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
43056 1 }
43057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
43058 {
43059 1 FFCore.itemScriptEngine();
43060 1 }
43061
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 if ((!( FFCore.system_suspend[susptHEROACTIVE] )) && doscript(ScriptType::Player) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255)
43062 {
43063 1 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
43064 1 }
43065
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && doscript(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
43066 {
43067 1 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[currdmap].script,currdmap);
43068 1 }
43069
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.doscript(ScriptType::ScriptedPassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
43070 {
43071 1 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script,currdmap);
43072 1 }
43073
2/8
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
43074 {
43075 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script);
43076 }
43077 }
43078 2 }
43079
43080 17426482 void FFScript::runF6Engine()
43081 {
43082
5/6
✓ Branch 0 taken 17425795 times.
✓ Branch 1 taken 687 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 17425781 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
17426482 if(!Quit && (GameFlags&GAMEFLAG_TRYQUIT) && !(GameFlags&GAMEFLAG_F6SCRIPT_ACTIVE))
43083 {
43084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(globalscripts[GLOBAL_SCRIPT_F6]->valid())
43085 {
43086 //Incase this was called mid-another script, store ref data
43087 push_ri();
43088 //
43089 clear_bitmap(f6_menu_buf);
43090 blit(framebuf, f6_menu_buf, 0, 0, 0, 0, 256, 224);
43091 initZScriptGlobalScript(GLOBAL_SCRIPT_F6);
43092 int32_t openingwipe = black_opening_count;
43093 int32_t openingshape = black_opening_shape;
43094 black_opening_count = 0; //No opening wipe during F6 menu
43095 if(black_opening_shape==bosFADEBLACK) black_fade(0);
43096 GameFlags |= GAMEFLAG_F6SCRIPT_ACTIVE;
43097 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
43098 pause_all_sfx();
43099
43100 auto& data = get_script_engine_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
43101 while (data.doscript)
43102 {
43103 script_drawing_commands.Clear();
43104 load_control_state();
43105 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_F6, GLOBAL_SCRIPT_F6);
43106 if (data.waitdraw)
43107 {
43108 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_F6, GLOBAL_SCRIPT_F6);
43109 data.waitdraw = false;
43110 }
43111 //Draw
43112 clear_bitmap(framebuf);
43113 if( !FFCore.system_suspend[susptCOMBOANIM] ) animate_combos();
43114 doScriptMenuDraws();
43115 //
43116 advanceframe(true,true,false);
43117 if(Quit) break; //Something quit, end script running
43118 }
43119 resume_all_sfx();
43120 script_drawing_commands.Clear();
43121 //script_drawing_commands.push_commands(tmpDrawCommands);
43122 GameFlags &= ~GAMEFLAG_F6SCRIPT_ACTIVE;
43123 //Restore opening wipe
43124 black_opening_count = openingwipe;
43125 black_opening_shape = openingshape;
43126 if(openingshape == bosFADEBLACK)
43127 {
43128 refreshTints();
43129 memcpy(tempblackpal, RAMpal, PAL_SIZE*sizeof(RGB));
43130 }
43131 //Restore script refinfo
43132 pop_ri();
43133 //
43134 if(!Quit)
43135 {
43136 if(!get_qr(qr_NOCONTINUE))
43137 f_Quit(qQUIT);
43138 }
43139 }
43140 14 else f_Quit(qQUIT);
43141 14 zc_readkey(KEY_F6);
43142 14 GameFlags &= ~GAMEFLAG_TRYQUIT;
43143 14 }
43144 17426482 }
43145 void FFScript::runOnDeathEngine()
43146 {
43147 if(!playerscripts[SCRIPT_PLAYER_DEATH]->valid()) return; //No script to run
43148 clear_bitmap(script_menu_buf);
43149 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
43150 initZScriptHeroScripts();
43151 GameFlags |= GAMEFLAG_SCRIPTMENU_ACTIVE;
43152 kill_sfx(); //No need to pause/resume; the player is dead.
43153 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
43154
43155 auto& data = get_script_engine_data(ScriptType::Player);
43156 while (data.doscript && !Quit)
43157 {
43158 script_drawing_commands.Clear();
43159 load_control_state();
43160 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_DEATH);
43161 if (data.waitdraw)
43162 {
43163 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_DEATH);
43164 data.waitdraw = false;
43165 }
43166 //Draw
43167 clear_bitmap(framebuf);
43168 if( !FFCore.system_suspend[susptCOMBOANIM] ) animate_combos();
43169 doScriptMenuDraws();
43170 //
43171 advanceframe(true);
43172 }
43173 script_drawing_commands.Clear();
43174 //script_drawing_commands.push_commands(tmpDrawCommands);
43175 GameFlags &= ~GAMEFLAG_SCRIPTMENU_ACTIVE;
43176 }
43177 122 void FFScript::runOnLaunchEngine()
43178 {
43179
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 2 times.
122 if(!globalscripts[GLOBAL_SCRIPT_ONLAUNCH]->valid()) return; //No script to run
43180 //Do NOT blit the prior screen to this bitmap; that would be the TITLE SCREEN.
43181 2 clear_to_color(script_menu_buf,BLACK);
43182 2 initZScriptGlobalScript(GLOBAL_SCRIPT_ONLAUNCH);
43183 2 GameFlags |= GAMEFLAG_SCRIPTMENU_ACTIVE;
43184 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
43185
43186 2 auto& data = get_script_engine_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
43187
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
4 while (data.doscript && !Quit)
43188 {
43189 2 script_drawing_commands.Clear();
43190 2 load_control_state();
43191 2 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH, GLOBAL_SCRIPT_ONLAUNCH);
43192
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (data.waitdraw)
43193 {
43194 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH, GLOBAL_SCRIPT_ONLAUNCH);
43195 data.waitdraw = false;
43196 }
43197 //Draw
43198 2 clear_bitmap(framebuf);
43199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if( !FFCore.system_suspend[susptCOMBOANIM] ) animate_combos();
43200
43201 2 doScriptMenuDraws();
43202 //
43203 2 advanceframe(true);
43204 }
43205 2 script_drawing_commands.Clear();
43206 //script_drawing_commands.push_commands(tmpDrawCommands);
43207 2 GameFlags &= ~GAMEFLAG_SCRIPTMENU_ACTIVE;
43208 122 }
43209 10 bool FFScript::runGenericFrozenEngine(const word script, const int32_t *init_data)
43210 {
43211 static int32_t local_i = 0;
43212
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if(script < 1 || script >= NUMSCRIPTSGENERIC) return false;
43213
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(init_data)
43214 {
43215 for(int q = 0; q < 8; ++q)
43216 {
43217 user_scripts[script].initd[q] = init_data[q];
43218 }
43219 }
43220
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(!genericscripts[script]->valid()) return false; //No script to run
43221 //Store script refinfo
43222 10 push_ri();
43223 refInfo local_ri;
43224 int32_t local_stack[MAX_SCRIPT_REGISTERS];
43225 10 local_ri.Clear();
43226 10 memset(local_stack, 0, sizeof(local_stack));
43227 10 genericActiveData.push_back(&local_ri);
43228 10 generic_active_stack.push_back(&local_stack);
43229 10 bool tmp_init = gen_active_initialized;
43230 10 bool tmp_doscript = gen_active_doscript;
43231 10 gen_active_doscript = true;
43232 10 gen_active_initialized = false;
43233 //run script
43234 10 uint32_t fl = GameFlags & GAMEFLAG_SCRIPTMENU_ACTIVE;
43235 10 BITMAP* tmpbuf = script_menu_buf;
43236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(fl)
43237 {
43238 script_menu_buf = create_bitmap_ex(8,256,224);
43239 }
43240 10 clear_bitmap(script_menu_buf);
43241 10 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
43242 10 GameFlags |= GAMEFLAG_SCRIPTMENU_ACTIVE;
43243 10 ++local_i;
43244 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
43245
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1542 times.
✓ Branch 2 taken 1542 times.
✓ Branch 3 taken 10 times.
1552 while(gen_active_doscript && !Quit)
43246 {
43247 1542 script_drawing_commands.Clear();
43248 1542 load_control_state();
43249 1542 ZScriptVersion::RunScript(ScriptType::GenericFrozen, script, local_i);
43250 //Draw
43251 1542 clear_bitmap(framebuf);
43252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1542 times.
1542 if( !FFCore.system_suspend[susptCOMBOANIM] ) animate_combos();
43253 1542 doScriptMenuDraws();
43254 //
43255 1542 advanceframe(true);
43256 }
43257 10 script_drawing_commands.Clear();
43258 //script_drawing_commands.push_commands(tmpDrawCommands);
43259 10 --local_i;
43260 10 gen_active_doscript = tmp_doscript;
43261 10 gen_active_initialized = tmp_init;
43262 //clear
43263 10 GameFlags &= ~GAMEFLAG_SCRIPTMENU_ACTIVE;
43264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(fl)
43265 {
43266 GameFlags |= fl;
43267 destroy_bitmap(script_menu_buf);
43268 script_menu_buf = tmpbuf;
43269 }
43270 10 genericActiveData.pop_back();
43271 10 generic_active_stack.pop_back();
43272 //Restore script refinfo
43273 10 pop_ri();
43274 10 return true;
43275 10 }
43276
43277 795 bool FFScript::runScriptedActiveSusbcreen()
43278 {
43279 795 word activesubscript = DMaps[currdmap].active_sub_script;
43280
3/4
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 754 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
795 if(!activesubscript || !dmapscripts[activesubscript]->valid()) return false; //No script to run
43281 41 word passivesubscript = DMaps[currdmap].passive_sub_script;
43282 41 word dmapactivescript = DMaps[currdmap].script;
43283 41 clear_bitmap(script_menu_buf);
43284 41 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
43285 41 initZScriptScriptedActiveSubscreen();
43286 41 GameFlags |= GAMEFLAG_SCRIPTMENU_ACTIVE;
43287 41 word script_dmap = currdmap;
43288 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
43289 41 pause_all_sfx();
43290 41 auto& data = get_script_engine_data(ScriptType::ScriptedActiveSubscreen);
43291
4/4
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 6772 times.
✓ Branch 2 taken 6772 times.
✓ Branch 3 taken 41 times.
6813 while (data.doscript && !Quit)
43292 {
43293 6772 script_drawing_commands.Clear();
43294 6772 load_control_state();
43295
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6772 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6772 if(get_qr(qr_DMAP_ACTIVE_RUNS_DURING_ACTIVE_SUBSCRIPT) && DMaps[script_dmap].script != 0 && doscript(ScriptType::DMap))
43296 {
43297 ZScriptVersion::RunScript(ScriptType::DMap, dmapactivescript, script_dmap);
43298 }
43299
4/6
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 6632 times.
✓ Branch 2 taken 140 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 140 times.
6772 if(get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_DURING_ACTIVE_SUBSCRIPT)!=0 && DMaps[script_dmap].passive_sub_script != 0 && FFCore.doscript(ScriptType::ScriptedPassiveSubscreen))
43300 {
43301 140 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, passivesubscript, script_dmap);
43302 140 }
43303 6772 ZScriptVersion::RunScript(ScriptType::ScriptedActiveSubscreen, activesubscript, script_dmap);
43304
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6772 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6772 if(waitdraw(ScriptType::DMap) && (get_qr(qr_DMAP_ACTIVE_RUNS_DURING_ACTIVE_SUBSCRIPT) && DMaps[script_dmap].script != 0 && doscript(ScriptType::DMap)))
43305 {
43306 ZScriptVersion::RunScript(ScriptType::DMap, dmapactivescript, script_dmap);
43307 waitdraw(ScriptType::DMap) = false;
43308 }
43309
5/8
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 6633 times.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 139 times.
6772 if(waitdraw(ScriptType::ScriptedPassiveSubscreen) && (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_DURING_ACTIVE_SUBSCRIPT)!=0 && DMaps[script_dmap].passive_sub_script != 0 && FFCore.doscript(ScriptType::ScriptedPassiveSubscreen)))
43310 {
43311 139 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, passivesubscript, script_dmap);
43312 139 waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
43313 139 }
43314
3/4
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 1300 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5472 times.
6772 if (data.waitdraw && data.doscript)
43315 {
43316 5472 ZScriptVersion::RunScript(ScriptType::ScriptedActiveSubscreen, activesubscript, script_dmap);
43317 5472 data.waitdraw = false;
43318 5472 }
43319 //Draw
43320 6772 clear_bitmap(framebuf);
43321
2/4
✓ Branch 0 taken 6772 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6772 times.
6772 if(currdmap == script_dmap && ( !FFCore.system_suspend[susptCOMBOANIM] ) ) animate_combos();
43322 6772 doScriptMenuDraws();
43323 //
43324 6772 advanceframe(true);
43325 //Handle warps; run game_loop once!
43326
1/2
✓ Branch 0 taken 6772 times.
✗ Branch 1 not taken.
6772 if(currdmap != script_dmap)
43327 {
43328 activesubscript = DMaps[currdmap].active_sub_script;
43329 if(!activesubscript || !dmapscripts[activesubscript]->valid()) return true; //No script to run
43330 passivesubscript = DMaps[currdmap].passive_sub_script;
43331 dmapactivescript = DMaps[currdmap].script;
43332 script_dmap = currdmap;
43333 //Reset the background image
43334 game_loop();
43335 clear_bitmap(script_menu_buf);
43336 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
43337 //Now loop without advancing frame, so that the subscreen script can draw immediately.
43338 }
43339 }
43340 41 resume_all_sfx();
43341 41 script_drawing_commands.Clear();
43342 //script_drawing_commands.push_commands(tmpDrawCommands);
43343 41 GameFlags &= ~GAMEFLAG_SCRIPTMENU_ACTIVE;
43344 41 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
43345 41 return true;
43346 795 }
43347 420 bool FFScript::runOnMapScriptEngine()
43348 {
43349 420 word onmap_script = DMaps[currdmap].onmap_script;
43350
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 417 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
420 if(!onmap_script || !dmapscripts[onmap_script]->valid()) return false; //No script to run
43351 3 clear_bitmap(script_menu_buf);
43352 3 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
43353 3 initZScriptOnMapScript();
43354 3 GameFlags |= GAMEFLAG_SCRIPTMENU_ACTIVE;
43355 3 word script_dmap = currdmap;
43356 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
43357 3 pause_all_sfx();
43358
43359 3 auto& data = get_script_engine_data(ScriptType::OnMap);
43360
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 114 times.
✓ Branch 3 taken 3 times.
117 while (data.doscript && !Quit)
43361 {
43362 114 script_drawing_commands.Clear();
43363 114 load_control_state();
43364 114 ZScriptVersion::RunScript(ScriptType::OnMap, onmap_script, script_dmap);
43365
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114 if (data.waitdraw && data.doscript)
43366 {
43367 ZScriptVersion::RunScript(ScriptType::OnMap, onmap_script, script_dmap);
43368 data.waitdraw = false;
43369 }
43370 //Draw
43371 114 clear_bitmap(framebuf);
43372
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if(currdmap == script_dmap && ( !FFCore.system_suspend[susptCOMBOANIM] ) ) animate_combos();
43373 114 doScriptMenuDraws();
43374 //
43375 114 advanceframe(true);
43376 //Handle warps; run game_loop once!
43377
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(currdmap != script_dmap)
43378 {
43379 onmap_script = DMaps[currdmap].onmap_script;
43380 if(!onmap_script || !dmapscripts[onmap_script]->valid()) return true; //No script to run
43381 script_dmap = currdmap;
43382 //Reset the background image
43383 game_loop();
43384 clear_bitmap(script_menu_buf);
43385 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
43386 //Now loop without advancing frame, so that the subscreen script can draw immediately.
43387 }
43388 }
43389 3 resume_all_sfx();
43390 3 script_drawing_commands.Clear();
43391 //script_drawing_commands.push_commands(tmpDrawCommands);
43392 3 GameFlags &= ~GAMEFLAG_SCRIPTMENU_ACTIVE;
43393 3 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
43394 3 return true;
43395 420 }
43396
43397 8430 void FFScript::doScriptMenuDraws()
43398 {
43399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8430 times.
8430 BITMAP* menu_buf = ((GameFlags & GAMEFLAG_F6SCRIPT_ACTIVE) != 0) ? f6_menu_buf : script_menu_buf;
43400 8430 blit(menu_buf, framebuf, 0, 0, 0, 0, 256, 224);
43401 //Script draws
43402 8430 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
43403 8430 }
43404
43405 102 void FFScript::runOnSaveEngine()
43406 {
43407
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(globalscripts[GLOBAL_SCRIPT_ONSAVE]->valid())
43408 {
43409 push_ri();
43410 //Prevent getting here via Quit from causing a forced-script-quit after 1000 commands!
43411 int32_t tQuit = Quit;
43412 Quit = 0;
43413 //
43414 initZScriptGlobalScript(GLOBAL_SCRIPT_ONSAVE);
43415 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE, GLOBAL_SCRIPT_ONSAVE);
43416 //
43417 pop_ri();
43418 Quit = tQuit;
43419 }
43420 102 }
43421
43422 8068418 bool FFScript::itemScriptEngine()
43423 {
43424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8068418 times.
8068418 if ( FFCore.system_suspend[susptITEMSCRIPTENGINE] ) return false;
43425 //zprint("Trying to check if an %s is running.\n","item script");
43426
2/2
✓ Branch 0 taken 2065515008 times.
✓ Branch 1 taken 8068418 times.
2073583426 for ( int32_t q = 0; q < MAXITEMS; q++ )
43427 {
43428
43429 //zprint("Checking item ID: %d\n",q);
43430
3/4
✓ Branch 0 taken 18895887 times.
✓ Branch 1 taken 2046619121 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18895887 times.
2065515008 if ( itemsbuf[q].script <= 0 || itemsbuf[q].script > NUMSCRIPTITEM ) continue; // > NUMSCRIPTITEM as someone could force an invaid script slot!
43431
43432 18895887 auto& data = get_script_engine_data(ScriptType::Item, q);
43433
2/2
✓ Branch 0 taken 3306 times.
✓ Branch 1 taken 18892581 times.
18895887 if ( data.doscript < 1 ) continue;
43434
43435 //Passive items
43436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3306 times.
3306 if (((itemsbuf[q].flags&ITEM_PASSIVESCRIPT)))
43437 {
43438 if(game->item[q] && (get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
43439 {
43440 if(get_qr(qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
43441 && current_item(itemsbuf[q].family) > itemsbuf[q].fam_type)
43442 data.doscript = 0;
43443 else ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q&0xFFF);
43444 if(!data.doscript) //Item script ended. Clear the data, if any remains.
43445 {
43446 data.ref.Clear();
43447 data.initialized = false;
43448 data.waitdraw = false;
43449 FFScript::deallocateAllScriptOwned(ScriptType::Item, q);
43450 }
43451 }
43452 }
43453 else
43454 {
43455
43456 //Normal Items
43457 //zprint("Running ItemScriptEngine() for item ID: %dn", q);
43458 /*! What happens here: When an item script is first run by the user using that utem, the script runs for one frame.
43459 After executing RunScript(), item_doscript is set to '1' in hero.cpp.
43460 If the quest allows the item to continue running, the itemScriptEngine() function ignores running the
43461 same item script (again) that frame, and insteads increments item_doscript to '2'.
43462 If item_doscript == 2, then we know we are on the second frame, and we run it perpetually.
43463 If the QR to enable item scripts to run for more than one frame is not enabled, then item_doscript is set to '0'.
43464 If the item flag 'PERPETUAL SCRIPT' is enabled, then we ignore the lack of item_doscript==2.
43465 This allows passive item scripts to function.
43466 */
43467
43468 3306 auto& data = get_script_engine_data(ScriptType::Item, q);
43469
43470
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3293 times.
3306 if ( data.doscript == 1 ) // FIrst frame, normally set in hero.cpp
43471 {
43472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if ( get_qr(qr_ITEMSCRIPTSKEEPRUNNING) )
43473 {
43474 13 data.doscript = 2;
43475 13 }
43476 13 }
43477
1/2
✓ Branch 0 taken 3293 times.
✗ Branch 1 not taken.
3293 else if (data.doscript == 2) //Second frame and later, if scripts continue to run.
43478 {
43479 3293 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q&0xFFF);
43480 3293 }
43481 else if (data.doscript == 3) //Run via itemdata->RunScript
43482 {
43483 if ( (get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
43484 {
43485 data.doscript = 2; //Reduce to normal run status
43486 }
43487 else
43488 {
43489 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q & 0xFFF);
43490 data.doscript = 0;
43491 }
43492 }
43493 else if(data.doscript==4) //Item set itself false, kill script and clear data here
43494 {
43495 data.doscript = 0;
43496 }
43497
2/2
✓ Branch 0 taken 3278 times.
✓ Branch 1 taken 28 times.
3306 if(data.doscript==0) //Item script ended. Clear the data, if any remains.
43498 {
43499 28 data.ref.Clear();
43500 28 data.initialized = false;
43501 28 data.waitdraw = false;
43502 28 FFScript::deallocateAllScriptOwned(ScriptType::Item, q);
43503 28 }
43504 }
43505 3306 }
43506 8068418 return false;
43507 8068418 }
43508
43509 8155543 bool FFScript::itemScriptEngineOnWaitdraw()
43510 {
43511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8155543 times.
8155543 if ( FFCore.system_suspend[susptITEMSCRIPTENGINE] ) return false;
43512 //zprint("Trying to check if an %s is running.\n","item script");
43513
2/2
✓ Branch 0 taken 2087819008 times.
✓ Branch 1 taken 8155543 times.
2095974551 for ( int32_t q = 0; q < MAXITEMS; q++ )
43514 {
43515 //zprint("Checking item ID: %d\n",q);
43516
3/4
✓ Branch 0 taken 19399133 times.
✓ Branch 1 taken 2068419875 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19399133 times.
2087819008 if ( itemsbuf[q].script <= 0 || itemsbuf[q].script > NUMSCRIPTITEM ) continue; // > NUMSCRIPTITEM as someone could force an invaid script slot!
43517
43518 19399133 auto& data = get_script_engine_data(ScriptType::Item, q);
43519
43520
2/2
✓ Branch 0 taken 3278 times.
✓ Branch 1 taken 19395855 times.
19399133 if ( data.doscript < 1 ) continue;
43521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3278 times.
3278 if (!data.waitdraw) continue;
43522 else data.waitdraw = false;
43523
43524 //zprint("Running ItemScriptEngine() for item ID: %dn", q);
43525 /*! What happens here: When an item script is first run by the user using that utem, the script runs for one frame.
43526 After executing RunScript(), item_doscript is set to '1' in hero.cpp.
43527 If the quest allows the item to continue running, the itemScriptEngine() function ignores running the
43528 same item script (again) that frame, and insteads increments item_doscript to '2'.
43529 If item_doscript == 2, then we know we are on the second frame, and we run it perpetually.
43530 If the QR to enable item scripts to run for more than one frame is not enabled, then item_doscript is set to '0'.
43531 If the item flag 'PERPETUAL SCRIPT' is enabled, then we ignore the lack of item_doscript==2.
43532 This allows passive item scripts to function.
43533 */
43534 //Passive items
43535 if ((itemsbuf[q].flags&ITEM_PASSIVESCRIPT))
43536 {
43537 if(game->item[q] && (get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
43538 {
43539 if(get_qr(qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
43540 && current_item(itemsbuf[q].family) > itemsbuf[q].fam_type)
43541 data.doscript = 0;
43542 else ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q&0xFFF);
43543 if(!data.doscript) //Item script ended. Clear the data, if any remains.
43544 {
43545 data.ref.Clear();
43546 data.initialized = false;
43547 data.waitdraw = false;
43548 FFScript::deallocateAllScriptOwned(ScriptType::Item, q);
43549 }
43550 }
43551 }
43552 else
43553 {
43554 //Normal items
43555 if ( data.doscript == 1 ) // FIrst frame, normally set in hero.cpp
43556 {
43557 if ( get_qr(qr_ITEMSCRIPTSKEEPRUNNING) )
43558 {
43559 data.doscript = 2;
43560 }
43561 else data.doscript = 0;
43562 }
43563 else if (data.doscript == 2) //Second frame and later, if scripts continue to run.
43564 {
43565 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q&0xFFF);
43566 }
43567 else if (data.doscript == 3) //Run via itemdata->RunScript
43568 {
43569 if ( (get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
43570 {
43571 data.doscript = 2; //Reduce to normal run status
43572 }
43573 else
43574 {
43575 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q & 0xFFF);
43576 data.doscript = 0;
43577 }
43578 }
43579 else if(data.doscript==4) //Item set itself false, kill script and clear data here.
43580 {
43581 data.doscript = 0;
43582 }
43583 if(!data.doscript) //Item script ended. Clear the data, if any remains.
43584 {
43585 data.ref.Clear();
43586 data.initialized = false;
43587 data.waitdraw = false;
43588 FFScript::deallocateAllScriptOwned(ScriptType::Item, q);
43589 }
43590 }
43591 }
43592 8155543 return false;
43593 8155543 }
43594 7337271 void FFScript::npcScriptEngineOnWaitdraw()
43595 {
43596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7337271 times.
7337271 if ( FFCore.system_suspend[susptNPCSCRIPTS] ) return;
43597 7337271 guys.run_script(MODE_WAITDRAW);
43598 7337271 }
43599
43600 7262845 void FFScript::eweaponScriptEngine()
43601 {
43602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7262845 times.
7262845 if ( FFCore.system_suspend[susptEWEAPONSCRIPTS] ) return;
43603 7262845 Ewpns.run_script(MODE_NORMAL);
43604 7262845 }
43605
43606 7337271 void FFScript::lweaponScriptEngineOnWaitdraw()
43607 {
43608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7337271 times.
7337271 if ( FFCore.system_suspend[susptLWEAPONSCRIPTS] ) return;
43609 7337271 Lwpns.run_script(MODE_WAITDRAW);
43610 7337271 }
43611
43612 7350156 void FFScript::eweaponScriptEngineOnWaitdraw()
43613 {
43614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7350156 times.
7350156 if ( FFCore.system_suspend[susptEWEAPONSCRIPTS] ) return;
43615 7350156 Ewpns.run_script(MODE_WAITDRAW);
43616 7350156 }
43617
43618 7262845 void FFScript::itemSpriteScriptEngine()
43619 {
43620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7262845 times.
7262845 if ( FFCore.system_suspend[susptITEMSPRITESCRIPTS] ) return;
43621 7262845 items.run_script(MODE_NORMAL);
43622 7262845 }
43623
43624 7350156 void FFScript::itemSpriteScriptEngineOnWaitdraw()
43625 {
43626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7350156 times.
7350156 if ( FFCore.system_suspend[susptITEMSPRITESCRIPTS] ) return;
43627 7350156 items.run_script(MODE_WAITDRAW);
43628 7350156 }
43629
43630
43631 int32_t FFScript::getTime(int32_t type)
43632 {
43633 //struct tm *tm_struct = localtime(time(NULL));
43634 struct tm * tm_struct;
43635 time_t sysRTC;
43636 time (&sysRTC);
43637 tm_struct = localtime (&sysRTC);
43638 int32_t rval = -1;
43639
43640 switch(type)
43641 {
43642 case curyear:
43643 {
43644 //Year format starts at 1900, yeat
43645 //A raw read of '2018' would be '118', so we add 1900 to it to derive the actual year.
43646 rval = tm_struct->tm_year + 1900; break;
43647
43648 }
43649 case curmonth:
43650 {
43651 //Months start at 0, but we want 1->12
43652 //al_trace("The current month is: %d\n",month);
43653 rval = tm_struct->tm_mon +1; break;
43654 }
43655 case curday_month:
43656 {
43657 rval = tm_struct->tm_mday; break;
43658 }
43659 case curday_week:
43660 {
43661 //It seems that weekdays are a value range of 1 to 7.
43662 rval = tm_struct->tm_wday; break;
43663 }
43664 case curhour:
43665 {
43666 rval = tm_struct->tm_hour; break;
43667 }
43668 case curminute:
43669 {
43670 rval = tm_struct->tm_min; break;
43671 }
43672 case cursecond:
43673 {
43674 rval = tm_struct->tm_sec; break;
43675 }
43676 case curdayyear:
43677 {
43678 //The day (n/365) out of the entire year.
43679 rval = tm_struct->tm_yday; break;
43680 }
43681 case curDST:
43682 {
43683 //Returns if the user is in a Time Zone with Daylight TIme of some sort.
43684 //View the time.h docs for the actual values of this struct element.
43685 rval = tm_struct->tm_isdst;; break;
43686 }
43687 default:
43688 {
43689 al_trace("Invalid category passed to GetSystemTime(%d)\n",type);
43690 rval = -1; break;
43691 }
43692
43693 }
43694 return rval;
43695 }
43696
43697 void FFScript::do_isdeadnpc()
43698 {
43699 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
43700 if(GuyH::loadNPC(ri->guyref, "npc->isDead") == SH::_NoError)
43701 {
43702 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
43703 //int32_t dead = (int32_t)e->Dead(GuyH::getNPCIndex(ri->guyref));
43704 //GuyH::getNPC()->Dead(GuyH::getNPCIndex(ri->guyref));
43705 set_register(sarg1,
43706 ((GuyH::getNPC()->dying && !GuyH::getNPC()->immortal)
43707 ? 10000 : 0));
43708 }
43709 else set_register(sarg1, 0);
43710 }
43711
43712
43713 void FFScript::do_canslidenpc()
43714 {
43715
43716 if(GuyH::loadNPC(ri->guyref, "npc->CanSlide") == SH::_NoError)
43717 {
43718 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
43719 //bool candoit = e->can_slide();
43720 set_register(sarg1, ((GuyH::getNPC()->can_slide()) ? 10000 : 0));
43721 }
43722 else set_register(sarg1, -10000);
43723 }
43724
43725 void FFScript::do_slidenpc()
43726 {
43727
43728 if(GuyH::loadNPC(ri->guyref, "npc->Slide()") == SH::_NoError)
43729 {
43730 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
43731 //bool candoit = e->slide();
43732 set_register(sarg1, ((GuyH::getNPC()->slide())*10000));
43733 }
43734 else set_register(sarg1, -10000);
43735 }
43736
43737 void FFScript::do_npc_stopbgsfx()
43738 {
43739 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
43740 if(GuyH::loadNPC(ri->guyref, "npc->StopBGSFX()") == SH::_NoError)
43741 {
43742 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
43743 //e->stop_bgsfx(GuyH::getNPCIndex(ri->guyref));
43744 GuyH::getNPC()->stop_bgsfx(GuyH::getNPCIndex(ri->guyref));
43745 }
43746 }
43747
43748 void FFScript::do_npc_delete()
43749 {
43750 if(GuyH::loadNPC(ri->guyref, "npc->Remove()") == SH::_NoError)
43751 {
43752 auto ind = GuyH::getNPCIndex(ri->guyref);
43753 GuyH::getNPC()->stop_bgsfx(ind);
43754 guys.del(ind);
43755 }
43756 }
43757
43758 2 void FFScript::do_lweapon_delete()
43759 {
43760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(0!=(s=checkLWpn(ri->lwpn,"Remove()")))
43761 {
43762
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(s==Hero.lift_wpn)
43763 {
43764 delete s;
43765 Hero.lift_wpn = nullptr;
43766 }
43767 2 else Lwpns.del(LwpnH::getLWeaponIndex(ri->lwpn));
43768 2 }
43769 2 }
43770
43771 void FFScript::do_eweapon_delete()
43772 {
43773 if(0!=(s=checkEWpn(ri->ewpn,"Remove()")))
43774 {
43775 Ewpns.del(EwpnH::getEWeaponIndex(ri->ewpn));
43776 }
43777 }
43778
43779 8 bool FFScript::do_itemsprite_delete()
43780 {
43781
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(0!=(s=checkItem(ri->itemref)))
43782 {
43783 8 auto ind = ItemH::getItemIndex(ri->itemref);
43784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!items.del(ind)) return false;
43785
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 8 times.
55 for(int32_t i=0; i<Lwpns.Count(); i++)
43786 {
43787 47 weapon *w = (weapon*)Lwpns.spr(i);
43788
43789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(w->dragging==ind)
43790 {
43791 w->dragging=-1;
43792 }
43793
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 else if(w->dragging>ind)
43794 {
43795 w->dragging-=1;
43796 }
43797 47 }
43798 8 return true;
43799 }
43800 return false;
43801 8 }
43802
43803 409 void FFScript::updateIncludePaths()
43804 {
43805 409 includePaths.clear();
43806 409 int32_t pos = 0;
43807
2/2
✓ Branch 0 taken 1227 times.
✓ Branch 1 taken 409 times.
1636 for ( int32_t q = 0; includePathString[pos]; ++q )
43808 {
43809 1227 int32_t dest = 0;
43810 1227 char buf[2048] = {0};
43811
4/4
✓ Branch 0 taken 1227 times.
✓ Branch 1 taken 9816 times.
✓ Branch 2 taken 9816 times.
✓ Branch 3 taken 1227 times.
11043 while(includePathString[pos] != ';' && includePathString[pos])
43812 {
43813 9816 buf[dest] = includePathString[pos];
43814 9816 ++pos;
43815 9816 ++dest;
43816 }
43817 1227 ++pos;
43818
1/2
✓ Branch 0 taken 1227 times.
✗ Branch 1 not taken.
1227 std::string str(buf);
43819
1/2
✓ Branch 0 taken 1227 times.
✗ Branch 1 not taken.
1227 includePaths.push_back(str);
43820 1227 }
43821 409 }
43822
43823 409 void FFScript::initRunString()
43824 {
43825 409 memset(scriptRunString,0,sizeof(scriptRunString));
43826 409 strcpy(scriptRunString,zc_get_config("Compiler","run_string","run",App::zscript));
43827 409 }
43828
43829 409 void FFScript::initIncludePaths()
43830 {
43831 409 memset(includePathString,0,sizeof(includePathString));
43832 409 FILE* f = fopen("includepaths.txt", "r");
43833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 409 times.
409 if(f)
43834 {
43835 int32_t pos = 0;
43836 int32_t c;
43837 do
43838 {
43839 c = fgetc(f);
43840 if(c!=EOF)
43841 includePathString[pos++] = c;
43842 }
43843 while(c!=EOF && pos<MAX_INCLUDE_PATH_CHARS);
43844 if(pos<MAX_INCLUDE_PATH_CHARS)
43845 includePathString[pos] = '\0';
43846 includePathString[MAX_INCLUDE_PATH_CHARS-1] = '\0';
43847 fclose(f);
43848 }
43849 409 else strcpy(includePathString, "include/;headers/;scripts/;");
43850 409 al_trace("Full path string is: ");
43851 409 safe_al_trace(includePathString);
43852 409 al_trace("\n");
43853 409 updateIncludePaths();
43854
43855
2/2
✓ Branch 0 taken 1227 times.
✓ Branch 1 taken 409 times.
1636 for ( size_t q = 0; q < includePaths.size(); ++q )
43856 {
43857 1227 al_trace("Include path %zu: ",q);
43858 1227 safe_al_trace(includePaths.at(q));
43859 1227 al_trace("\n");
43860 1227 }
43861 409 }
43862
43863 void FFScript::do_npcattack()
43864 {
43865
43866 if(GuyH::loadNPC(ri->guyref, "npc->Attack()") == SH::_NoError)
43867 {
43868 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
43869 //e->FireWeapon();
43870 //we could just do:
43871 GuyH::getNPC()->FireWeapon();
43872 }
43873 }
43874 void FFScript::do_npc_newdir()
43875 {
43876 int32_t arrayptr = get_register(sarg1) / 10000;
43877 ArrayManager am(arrayptr);
43878 if(am.invalid()) return;
43879 int32_t sz = am.size();
43880
43881 if(GuyH::loadNPC(ri->guyref, "npc->NewDir()") == SH::_NoError)
43882 {
43883 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
43884
43885 if ( sz != -1 )
43886 {
43887 if ( sz != 3 )
43888 {
43889 Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
43890 return;
43891 }
43892 GuyH::getNPC()->newdir((am.get(0)/10000), (am.get(1)/10000),
43893 (am.get(2)/10000));
43894 }
43895 //else e->newdir();
43896 else GuyH::getNPC()->newdir();
43897 }
43898 }
43899
43900 void FFScript::do_npc_constwalk()
43901 {
43902 int32_t arrayptr = get_register(sarg1) / 10000;
43903 ArrayManager am(arrayptr);
43904 if(am.invalid()) return;
43905 int32_t sz = am.size();
43906
43907 if(GuyH::loadNPC(ri->guyref, "npc->ConstantWalk()") == SH::_NoError)
43908 {
43909 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
43910
43911 if ( sz != -1 )
43912 {
43913 if ( sz != 3 )
43914 {
43915 Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
43916 return;
43917 }
43918 GuyH::getNPC()->constant_walk( (am.get(0)/10000), (am.get(1)/10000),
43919 (am.get(2)/10000) );
43920 }
43921 else GuyH::getNPC()->constant_walk();//e->constant_walk();
43922 }
43923 }
43924
43925 void FFScript::do_npc_varwalk()
43926 {
43927 int32_t arrayptr = get_register(sarg2) / 10000;
43928 ArrayManager am(arrayptr);
43929 if(am.invalid()) return;
43930 int32_t sz = am.size();
43931
43932 if(GuyH::loadNPC(ri->guyref, "npc->VariableWalk()") == SH::_NoError)
43933 {
43934 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
43935
43936 if ( sz == 3 )
43937 {
43938
43939 GuyH::getNPC()->variable_walk( (am.get(0)/10000), (am.get(1)/10000),
43940 (am.get(2)/10000) );
43941 }
43942 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
43943 }
43944 }
43945
43946 void FFScript::do_npc_varwalk8()
43947 {
43948 int32_t arrayptr = get_register(sarg1) / 10000;
43949 ArrayManager am(arrayptr);
43950 if(am.invalid()) return;
43951 int32_t sz = am.size();
43952
43953 if(GuyH::loadNPC(ri->guyref, "npc->VariableWalk8()") == SH::_NoError)
43954 {
43955 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
43956
43957 if ( sz == 4 )
43958 {
43959 GuyH::getNPC()->variable_walk_8( (am.get(0)/10000), (am.get(1)/10000),
43960 (am.get(2)/10000), (am.get(3)/10000) );
43961 }
43962 else if ( sz == 8 )
43963 {
43964 GuyH::getNPC()->variable_walk_8( (am.get(0)/10000), (am.get(1)/10000),
43965 (am.get(2)/10000), (am.get(3)/10000),
43966 (am.get(4)/10000), (am.get(5)/10000),
43967 (am.get(6)/10000), (am.get(7)/10000)
43968 );
43969 }
43970 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
43971 }
43972 }
43973
43974 void FFScript::do_npc_constwalk8()
43975 {
43976 int32_t arrayptr = get_register(sarg1) / 10000;
43977 ArrayManager am(arrayptr);
43978 if(am.invalid()) return;
43979 int32_t sz = am.size();
43980
43981 if(GuyH::loadNPC(ri->guyref, "npc->ConstantWalk8()") == SH::_NoError)
43982 {
43983 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
43984
43985 if ( sz == 3 )
43986 {
43987 GuyH::getNPC()->constant_walk_8( (am.get(0)/10000), (am.get(1)/10000),
43988 (am.get(2)/10000) );
43989 }
43990
43991 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
43992 }
43993 }
43994
43995
43996 void FFScript::do_npc_haltwalk()
43997 {
43998 int32_t arrayptr = get_register(sarg1) / 10000;
43999 ArrayManager am(arrayptr);
44000 if(am.invalid()) return;
44001 int32_t sz = am.size();
44002
44003 if(GuyH::loadNPC(ri->guyref, "npc->HaltingWalk()") == SH::_NoError)
44004 {
44005 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
44006
44007 if ( sz == 5 )
44008 {
44009 GuyH::getNPC()->halting_walk( (am.get(0)/10000), (am.get(1)/10000),
44010 (am.get(2)/10000), (am.get(3)/10000),
44011 (am.get(4)/10000));
44012 }
44013 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
44014 }
44015 }
44016
44017 void FFScript::do_npc_haltwalk8()
44018 {
44019 int32_t arrayptr = get_register(sarg1) / 10000;
44020 ArrayManager am(arrayptr);
44021 if(am.invalid()) return;
44022 int32_t sz = am.size();
44023
44024 if(GuyH::loadNPC(ri->guyref, "npc->HaltingWalk8()") == SH::_NoError)
44025 {
44026 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
44027
44028 if ( sz == 6 )
44029 {
44030
44031 GuyH::getNPC()->halting_walk_8( (am.get(0)/10000), (am.get(1)/10000),
44032 (am.get(2)/10000), (am.get(3)/10000),
44033 (am.get(4)/10000),(am.get(5)/10000));
44034 }
44035 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
44036 }
44037 }
44038
44039
44040 void FFScript::do_npc_floatwalk()
44041 {
44042 int32_t arrayptr = get_register(sarg1) / 10000;
44043 ArrayManager am(arrayptr);
44044 if(am.invalid()) return;
44045 int32_t sz = am.size();
44046
44047 if(GuyH::loadNPC(ri->guyref, "npc->FloatingWalk()") == SH::_NoError)
44048 {
44049 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
44050
44051 if ( sz == 3 )
44052 {
44053
44054 GuyH::getNPC()->floater_walk( (am.get(0)/10000), (am.get(1)/10000),
44055 (zfix)(am.get(2)/10000));
44056
44057 }
44058 else if ( sz == 7 )
44059 {
44060
44061 GuyH::getNPC()->floater_walk( (am.get(0)/10000), (am.get(1)/10000),
44062 (zfix)(am.get(2)/10000), (zfix)(am.get(3)/10000),
44063 (am.get(4)/10000),(am.get(5)/10000),
44064 (am.get(6)/10000));
44065 }
44066 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
44067 }
44068 }
44069
44070 void FFScript::do_npc_breathefire()
44071 {
44072 bool seek = (get_register(sarg1));
44073 if(GuyH::loadNPC(ri->guyref, "npc->BreathAttack()") == SH::_NoError)
44074 {
44075 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
44076 GuyH::getNPC()->FireBreath(seek);
44077
44078 }
44079 }
44080
44081
44082 void FFScript::do_npc_newdir8()
44083 {
44084 int32_t arrayptr = get_register(sarg1) / 10000;
44085 ArrayManager am(arrayptr);
44086 if(am.invalid()) return;
44087 int32_t sz = am.size();
44088
44089 if(GuyH::loadNPC(ri->guyref, "npc->NewDir8()") == SH::_NoError)
44090 {
44091 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
44092
44093 if ( sz == 3 )
44094 {
44095
44096 GuyH::getNPC()->newdir_8( (am.get(0)/10000), (am.get(1)/10000),
44097 (am.get(2)/10000));
44098
44099 }
44100 else if ( sz == 7 )
44101 {
44102
44103 GuyH::getNPC()->newdir_8( (am.get(0)/10000), (am.get(1)/10000),
44104 (am.get(2)/10000), (am.get(3)/10000),
44105 (am.get(4)/10000),(am.get(5)/10000),
44106 (am.get(6)/10000));
44107 }
44108 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
44109 }
44110 }
44111
44112
44113 int32_t FFScript::npc_collision()
44114 {
44115 int32_t isColl = 0;
44116 if(GuyH::loadNPC(ri->guyref, "npc->Collision()") == SH::_NoError)
44117 {
44118 int32_t _obj_type = (ri->d[rINDEX] / 10000);
44119 int32_t _obj_ptr = (ri->d[rINDEX2]);
44120
44121 switch(_obj_type)
44122 {
44123 case obj_type_lweapon:
44124 {
44125 isColl = 0;
44126 break;
44127 }
44128 case obj_type_eweapon:
44129 {
44130 isColl = 0;
44131 break;
44132 }
44133 case obj_type_npc:
44134 {
44135 isColl = 0;
44136 break;
44137 }
44138 case obj_type_player:
44139 {
44140 isColl = 0;
44141 break;
44142 }
44143 case obj_type_ffc:
44144 {
44145 _obj_ptr *= 10000; _obj_ptr -= 1;
44146 isColl = 0;
44147 break;
44148 }
44149 case obj_type_combo_pos:
44150 {
44151 _obj_ptr *= 10000;
44152 isColl = 0;
44153 break;
44154 }
44155 case obj_type_item:
44156 {
44157 isColl = 0;
44158 break;
44159 }
44160 default:
44161 {
44162 Z_scripterrlog("Invalid object type (%d) passed to npc->Collision(int32_t type, int32_t ptr)\n", _obj_type);
44163 isColl = 0;
44164 break;
44165 }
44166 }
44167 }
44168
44169 return isColl;
44170 }
44171
44172
44173 int32_t FFScript::npc_linedup()
44174 {
44175 if(GuyH::loadNPC(ri->guyref, "npc->LinedUp()") == SH::_NoError)
44176 {
44177 int32_t range = (ri->d[rINDEX] / 10000);
44178 bool dir8 = (ri->d[rINDEX2]);
44179 return (int32_t)(GuyH::getNPC()->lined_up(range,dir8)*10000);
44180 }
44181
44182 return 0;
44183 }
44184
44185
44186 void FFScript::do_npc_hero_in_range(const bool v)
44187 {
44188 int32_t dist = get_register(sarg1) / 10000;
44189 if(GuyH::loadNPC(ri->guyref, "npc->LinedUp()") == SH::_NoError)
44190 {
44191 bool in_range = GuyH::getNPC()->HeroInRange(dist);
44192 set_register(sarg1, (in_range ? 10000 : 0)); //This isn't setting the right value, it seems.
44193 }
44194 else set_register(sarg2, 0);
44195 }
44196
44197
44198
44199
44200
44201
44202 void FFScript::do_npc_simulate_hit(const bool v)
44203 {
44204 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
44205 ArrayManager am(arrayptr);
44206 if(am.invalid()) return;
44207 int32_t sz = am.size();
44208 bool ishit = false;
44209
44210 if(GuyH::loadNPC(ri->guyref, "npc->SimulateHit()") == SH::_NoError)
44211 {
44212 // zprint("Trying to simulate a hit on npc\n");
44213 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
44214 if ( sz == 2 ) //type and pointer
44215 {
44216 // int32_t type = am.get(0)/10000;
44217
44218 //switch(type)
44219 //{
44220 // case simulate_hit_type_weapon:
44221 // {
44222 // ishit = e->hit(*);
44223 // break;
44224 // }
44225 // case simulate_hit_type_sprite:
44226 // {
44227 // ishit = e->hit(*);
44228 // break;
44229 // }
44230 //}
44231 ishit = false;
44232 }
44233 if ( sz == 6 ) //hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz);
44234 {
44235 ishit = GuyH::getNPC()->hit( (am.get(0)/10000), (am.get(1)/10000),
44236 (am.get(2)/10000), (am.get(3)/10000),
44237 (am.get(4)/10000), (am.get(5)/10000) );
44238
44239 }
44240 else
44241 {
44242 Z_scripterrlog("Invalid array size (%d) passed to npc->SimulateHit(). The array size must be [1] or [3].\n", sz);
44243 ishit = false;
44244 }
44245 }
44246 set_register(sarg1, ( ishit ? 10000 : 0));
44247 }
44248
44249 void FFScript::do_npc_knockback(const bool v)
44250 {
44251 int32_t time = SH::get_arg(sarg1, v) / 10000;
44252 int32_t dir = SH::get_arg(sarg2, v) / 10000;
44253 int32_t spd = vbound(ri->d[rINDEX] / 10000, 0, 255);
44254 //zprint("Knockback: time %d,dir %d,spd %d\n",time,dir,spd);
44255 bool ret = false;
44256
44257 if(GuyH::loadNPC(ri->guyref, "npc->Knockback()") == SH::_NoError)
44258 {
44259 ret = GuyH::getNPC()->knockback(time, dir, spd);
44260 }
44261 set_register(sarg1, ( ret ? 10000 : 0));
44262 }
44263
44264 void FFScript::do_npc_add(const bool v)
44265 {
44266
44267 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
44268 ArrayManager am(arrayptr);
44269 if(am.invalid()) return;
44270 int32_t sz = am.size();
44271
44272 int32_t id = 0, nx = 0, ny = 0;
44273
44274 if ( sz < 1 )
44275 {
44276 Z_scripterrlog("Invalid array size (%d) passed to npc->Create(). The array size must be [1] or [3].\n", sz);
44277 return;
44278 }
44279 else //size is valid
44280 {
44281 id = (am.get(0)/10000);
44282
44283 if ( sz == 3 ) //x and y
44284 {
44285 nx = (am.get(1)/10000);
44286 ny = (am.get(2)/10000);
44287 }
44288 }
44289
44290
44291 if(BC::checkGuyID(id, "npc->Create()") != SH::_NoError)
44292 return;
44293
44294 //If we make a segmented enemy there'll be more than one sprite created
44295 word numcreated = addenemy(nx, ny, id, -10);
44296
44297 if(numcreated == 0)
44298 {
44299 ri->guyref = MAX_DWORD;
44300 Z_scripterrlog("Couldn't create NPC \"%s\", screen NPC limit reached\n", guy_string[id]);
44301 }
44302 else
44303 {
44304 word index = guys.Count() - numcreated; //Get the main enemy, not a segment
44305 ri->guyref = guys.spr(index)->getUID();
44306
44307 for(; index<guys.Count(); index++)
44308 ((enemy*)guys.spr(index))->script_spawned=true;
44309
44310 ri->d[rEXP1] = ri->guyref;
44311 ri->d[rEXP2] = ri->guyref;
44312 Z_eventlog("Script created NPC \"%s\" with UID = %ld\n", guy_string[id], ri->guyref);
44313 }
44314 }
44315
44316 bool FFScript::checkExtension(std::string &filename, const std::string &extension)
44317 //inline bool checkExtension(std::string filename, std::string extension)
44318 {
44319 int32_t dot = filename.find_last_of(".");
44320 std::string exten = (dot == std::string::npos ? "" : filename.substr(dot, filename.length() - dot));
44321 return exten == extension;
44322 }
44323
44324
44325 void FFScript::do_loadgamestructs(const bool v, const bool v2)
44326 {
44327 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
44328 int32_t section_id = SH::get_arg(sarg2, v2) / 10000;
44329 zprint("do_loadgamestructs selected section is: %d\n", section_id);
44330 //Bitwise OR sections together
44331 string strA;
44332 ArrayH::getString(arrayptr, strA, 256);
44333 int32_t temp_sram_flags = section_id; int32_t sram_version = 0;
44334
44335 if ( FFCore.checkExtension(strA, ".zcsram") )
44336 {
44337 PACKFILE *f = pack_fopen_password(strA.c_str(),F_READ, "");
44338 if (f)
44339 {
44340 p_igetl(&sram_version,f);
44341 p_igetl(&section_id,f);
44342 zprint("Reading ZCSRAM, Version: %d\n", sram_version);
44343 if ( sram_version > SRAM_VERSION ) //file version is greater than programme current version.
44344 {
44345 Z_scripterrlog("SRAM Version is from a version of ZC newer than the running version and cannot be loaded.\n");
44346 return;
44347 }
44348 if ( section_id != temp_sram_flags )
44349 {
44350 Z_scripterrlog("Reading an SRAM file with a section flag mismatch!\nThe file section flags are (%d) and the specified flagset is (%d).\nThis may cause errors!\n", section_id, temp_sram_flags);
44351 }
44352
44353 if ( !section_id || section_id&svGUYS ) FFCore.read_enemies(f,sram_version);
44354 if ( !section_id || section_id&svITEMS )FFCore.read_items(f,sram_version);
44355 if ( !section_id || section_id&svWEAPONS ) FFCore.read_weaponsprtites(f,sram_version);
44356 if ( !section_id || section_id&svCOMBOS )
44357 {
44358 reset_combo_animations();
44359 reset_combo_animations2();
44360 FFCore.read_combos(f,sram_version);
44361 }
44362 if ( !section_id || section_id&svDMAPS ) FFCore.read_dmaps(f,sram_version);
44363 if ( !section_id || section_id&svMAPSCR ) FFCore.read_mapscreens(f,sram_version);
44364 pack_fclose(f);
44365 zprint("do_savegamestructs COMPLETED READINV %s, with section ID flags %d\n", "ALL", section_id);
44366
44367 set_register(sarg1, 10000);
44368 }
44369 else
44370 {
44371 Z_scripterrlog("FFCore.do_loadgamestructs could not read packfile!");
44372 set_register(sarg1, -10000);
44373 }
44374 }
44375 else
44376 {
44377 Z_scripterrlog("Tried to read a .zcsram file, but the file lacked the ..zcsram extension!\n");
44378 set_register(sarg1, -20000);
44379
44380 }
44381 }
44382
44383 void FFScript::do_savegamestructs(const bool v, const bool v2)
44384 {
44385 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
44386 int32_t section_id = SH::get_arg(sarg2, v2) / 10000;
44387 zprint("do_loadgamestructs selected section is: %d\n", section_id);
44388 //Bitwise OR sections together
44389 string strA;
44390 ArrayH::getString(arrayptr, strA, 256);
44391 int32_t cycles = 0;
44392
44393 if ( FFCore.checkExtension(strA, ".zcsram") )
44394 {
44395 PACKFILE *f = pack_fopen_password(strA.c_str(),F_WRITE, "");
44396 if (f)
44397 {
44398 p_iputl(SRAM_VERSION,f);
44399 p_iputl(section_id,f);
44400
44401 if ( !section_id || section_id&svGUYS ) FFCore.write_enemies(f,SRAM_VERSION);
44402 if ( !section_id || section_id&svITEMS ) FFCore.write_items(f,SRAM_VERSION);
44403 if ( !section_id || section_id&svWEAPONS ) FFCore.write_weaponsprtites(f,SRAM_VERSION);
44404 if ( !section_id || section_id&svCOMBOS )
44405 {
44406 reset_combo_animations();
44407 reset_combo_animations2();
44408 FFCore.write_combos(f,SRAM_VERSION);
44409 }
44410 if ( !section_id || section_id&svDMAPS ) FFCore.write_dmaps(f,SRAM_VERSION);
44411 if ( !section_id || section_id&svMAPSCR ) FFCore.write_mapscreens(f,SRAM_VERSION);
44412 pack_fclose(f);
44413 zprint("do_savegamestructs COMPLETED WRITING %s, with section ID flags %d\n", "ALL", section_id);
44414 set_register(sarg1, 10000);
44415 }
44416 else
44417 {
44418 Z_scripterrlog("FFCore.do_loadgamestructs could not read packfile!");
44419 set_register(sarg1, -10000);
44420 }
44421 }
44422 else
44423 {
44424 Z_scripterrlog("Tried to write a .zcsram file, but the file lacked the ..zcsram extension!\n");
44425 set_register(sarg1, -20000);
44426 }
44427 }
44428
44429 1 void FFScript::do_strcmp()
44430 {
44431 1 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000 ?
44432 1 int32_t arrayptr_b = ri->d[rINDEX2]/10000; //get_register(sarg2) / 10000?
44433 1 string strA;
44434 1 string strB;
44435
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 ArrayH::getString(arrayptr_a, strA);
44436
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 ArrayH::getString(arrayptr_b, strB);
44437
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 set_register(sarg1, (strcmp(strA.c_str(), strB.c_str()) * 10000));
44438 1 }
44439
44440 void FFScript::do_stricmp()
44441 {
44442 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
44443 int32_t arrayptr_b = ri->d[rINDEX2]/10000; //get_register(sarg2) / 10000?
44444 string strA;
44445 string strB;
44446 ArrayH::getString(arrayptr_a, strA);
44447 ArrayH::getString(arrayptr_b, strB);
44448 set_register(sarg1, (stricmp(strA.c_str(), strB.c_str()) * 10000));
44449 }
44450
44451 1 void FFScript::do_LowerToUpper(const bool v)
44452 {
44453
44454 1 int32_t arrayptr_a = get_register(sarg1) / 10000;
44455 1 string strA;
44456
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 ArrayH::getString(arrayptr_a, strA);
44457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( strA.size() < 1 )
44458 {
44459 Z_scripterrlog("String passed to UpperToLower() is too small. Size is: %d \n", strA.size());
44460 set_register(sarg1, 0); return;
44461 }
44462
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
6 for ( size_t q = 0; q < strA.size(); ++q )
44463 {
44464
3/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
5 strA[q] -= 32 * (strA[q] >= 'a' && strA[q] <= 'z');
44465 //if(( strA[q] >= 'a' && strA[q] <= 'z' ) || ( strA[q] >= 'A' && strA[q] <= 'Z' ))
44466 //{
44467 // if ( strA[q] < 'a' ) { continue; }
44468 // else strA[q] -= 32;
44469 // continue;
44470 //}
44471
44472 5 }
44473 //zprint("Converted string is: %s \n", strA.c_str());
44474
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
44475 {
44476 Z_scripterrlog("Dest string supplied to 'LowerToUpper()' not large enough\n");
44477 set_register(sarg1, 0);
44478 }
44479
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 else set_register(sarg1, (10000));
44480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 }
44481
44482 void FFScript::do_UpperToLower(const bool v)
44483 {
44484
44485 int32_t arrayptr_a = get_register(sarg1) / 10000;
44486 string strA;
44487 ArrayH::getString(arrayptr_a, strA);
44488 if ( strA.size() < 1 )
44489 {
44490 Z_scripterrlog("String passed to UpperToLower() is too small. Size is: %d \n", strA.size());
44491 set_register(sarg1, 0); return;
44492 }
44493 for ( size_t q = 0; q < strA.size(); ++q )
44494 {
44495 strA[q] += 32 * (strA[q] >= 'A' && strA[q] <= 'Z');
44496 //if(( strA[q] >= 'a' && strA[q] <= 'z' ) || ( strA[q] >= 'A' && strA[q] <= 'Z' ))
44497 //{
44498 // if ( strA[q] < 'a' ) { strA[q] += 32; }
44499 // else continue;
44500 // continue;
44501 //}
44502 }
44503 //zprint("Converted string is: %s \n", strA.c_str());
44504 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
44505 {
44506 Z_scripterrlog("Dest string supplied to 'LowerToUpper()' not large enough\n");
44507 set_register(sarg1, 0);
44508 }
44509 else set_register(sarg1, (10000));
44510 }
44511
44512 void FFScript::do_getnpcscript()
44513 {
44514 int32_t arrayptr = get_register(sarg1) / 10000;
44515 string the_string;
44516 int32_t script_num = -1;
44517 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44518
44519 for(int32_t q = 0; q < NUMSCRIPTGUYS; q++)
44520 {
44521 if(!(strcmp(the_string.c_str(), npcmap[q].scriptname.c_str())))
44522 {
44523 script_num = q+1;
44524 break;
44525 }
44526 }
44527 set_register(sarg1, (script_num * 10000));
44528 }
44529
44530 void FFScript::do_getcomboscript()
44531 {
44532 int32_t arrayptr = get_register(sarg1) / 10000;
44533 string the_string;
44534 int32_t script_num = -1;
44535 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44536
44537 for(int32_t q = 0; q < NUMSCRIPTSCOMBODATA; q++)
44538 {
44539 if(!(strcmp(the_string.c_str(), comboscriptmap[q].scriptname.c_str())))
44540 {
44541 script_num = q+1;
44542 break;
44543 }
44544 }
44545 set_register(sarg1, (script_num * 10000));
44546 }
44547
44548 68 void FFScript::do_getgenericscript()
44549 {
44550 68 int32_t arrayptr = get_register(sarg1) / 10000;
44551 68 string the_string;
44552 68 int32_t script_num = -1;
44553
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44554
44555 // zprint2("Searching for generic script named '%s'\n", the_string.c_str());
44556
1/2
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
361 for(int32_t q = 0; q < NUMSCRIPTSGENERIC; q++)
44557 {
44558 // if(genericmap[q].scriptname.size()>2)
44559 // zprint2("Checking against '%s'...\n", genericmap[q].scriptname.c_str());
44560
3/4
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 68 times.
361 if(!(strcmp(the_string.c_str(), genericmap[q].scriptname.c_str())))
44561 {
44562 68 script_num = q+1;
44563 68 break;
44564 }
44565 293 }
44566
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 set_register(sarg1, (script_num * 10000));
44567 68 }
44568
44569 602 void FFScript::do_getlweaponscript()
44570 {
44571 602 int32_t arrayptr = get_register(sarg1) / 10000;
44572 602 string the_string;
44573 602 int32_t script_num = -1;
44574
1/2
✓ Branch 0 taken 602 times.
✗ Branch 1 not taken.
602 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44575
44576
1/2
✓ Branch 0 taken 17373 times.
✗ Branch 1 not taken.
17373 for(int32_t q = 0; q < NUMSCRIPTWEAPONS; q++)
44577 {
44578
3/4
✓ Branch 0 taken 17373 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16771 times.
✓ Branch 3 taken 602 times.
17373 if(!(strcmp(the_string.c_str(), lwpnmap[q].scriptname.c_str())))
44579 {
44580 602 script_num = q+1;
44581 602 break;
44582 }
44583 16771 }
44584
1/2
✓ Branch 0 taken 602 times.
✗ Branch 1 not taken.
602 set_register(sarg1, (script_num * 10000));
44585 602 }
44586 1275 void FFScript::do_geteweaponscript()
44587 {
44588 1275 int32_t arrayptr = get_register(sarg1) / 10000;
44589 1275 string the_string;
44590 1275 int32_t script_num = -1;
44591
1/2
✓ Branch 0 taken 1275 times.
✗ Branch 1 not taken.
1275 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44592
44593
1/2
✓ Branch 0 taken 29109 times.
✗ Branch 1 not taken.
29109 for(int32_t q = 0; q < NUMSCRIPTWEAPONS; q++)
44594 {
44595
3/4
✓ Branch 0 taken 29109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27834 times.
✓ Branch 3 taken 1275 times.
29109 if(!(strcmp(the_string.c_str(), ewpnmap[q].scriptname.c_str())))
44596 {
44597 1275 script_num = q+1;
44598 1275 break;
44599 }
44600 27834 }
44601
1/2
✓ Branch 0 taken 1275 times.
✗ Branch 1 not taken.
1275 set_register(sarg1, (script_num * 10000));
44602 1275 }
44603 void FFScript::do_getheroscript()
44604 {
44605 int32_t arrayptr = get_register(sarg1) / 10000;
44606 string the_string;
44607 int32_t script_num = -1;
44608 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44609
44610 for(int32_t q = 0; q < NUMSCRIPTPLAYER; q++)
44611 {
44612 if(!(strcmp(the_string.c_str(), playermap[q].scriptname.c_str())))
44613 {
44614 script_num = q+1;
44615 break;
44616 }
44617 }
44618 set_register(sarg1, (script_num * 10000));
44619 }
44620 void FFScript::do_getglobalscript()
44621 {
44622 int32_t arrayptr = get_register(sarg1) / 10000;
44623 string the_string;
44624 int32_t script_num = -1;
44625 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44626
44627 for(int32_t q = 0; q < NUMSCRIPTGLOBAL; q++)
44628 {
44629 if(!(strcmp(the_string.c_str(), globalmap[q].scriptname.c_str())))
44630 {
44631 script_num = q+1;
44632 break;
44633 }
44634 }
44635 set_register(sarg1, (script_num * 10000));
44636 }
44637 105 void FFScript::do_getdmapscript()
44638 {
44639 105 int32_t arrayptr = get_register(sarg1) / 10000;
44640 105 string the_string;
44641 105 int32_t script_num = -1;
44642
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44643
44644
1/2
✓ Branch 0 taken 590 times.
✗ Branch 1 not taken.
590 for(int32_t q = 0; q < NUMSCRIPTSDMAP; q++)
44645 {
44646
3/4
✓ Branch 0 taken 590 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 485 times.
✓ Branch 3 taken 105 times.
590 if(!(strcmp(the_string.c_str(), dmapmap[q].scriptname.c_str())))
44647 {
44648 105 script_num = q+1;
44649 105 break;
44650 }
44651 485 }
44652
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 set_register(sarg1, (script_num * 10000));
44653 105 }
44654 void FFScript::do_getscreenscript()
44655 {
44656 int32_t arrayptr = get_register(sarg1) / 10000;
44657 string the_string;
44658 int32_t script_num = -1;
44659 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44660
44661 for(int32_t q = 0; q < NUMSCRIPTSCREEN; q++)
44662 {
44663 if(!(strcmp(the_string.c_str(), screenmap[q].scriptname.c_str())))
44664 {
44665 script_num = q+1;
44666 break;
44667 }
44668 }
44669 set_register(sarg1, (script_num * 10000));
44670 }
44671 31 void FFScript::do_getitemspritescript()
44672 {
44673 31 int32_t arrayptr = get_register(sarg1) / 10000;
44674 31 string the_string;
44675 31 int32_t script_num = -1;
44676
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44677
44678
1/2
✓ Branch 0 taken 273 times.
✗ Branch 1 not taken.
273 for(int32_t q = 0; q < NUMSCRIPTSITEMSPRITE; q++)
44679 {
44680
3/4
✓ Branch 0 taken 273 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242 times.
✓ Branch 3 taken 31 times.
273 if(!(strcmp(the_string.c_str(), itemspritemap[q].scriptname.c_str())))
44681 {
44682 31 script_num = q+1;
44683 31 break;
44684 }
44685 242 }
44686
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 set_register(sarg1, (script_num * 10000));
44687 31 }
44688 //Not assigned to slots at present. If they ever are, then this would get the id of any script (any type) by name. -Z
44689 void FFScript::do_getuntypedscript()
44690 {
44691 set_register(sarg1, 0);
44692 //int32_t arrayptr = ri->d[rINDEX]/10000;
44693 //string the_string;
44694 //int32_t script_num = -1;
44695 //ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44696
44697 //for(int32_t q = 0; q < NUMSCRIPTSITEMSPRITE; q++)
44698 //{
44699 // if(!(strcmp(the_string.c_str(), itemspritemap[q].scriptname.c_str())))
44700 // {
44701 // script_num = q+1;
44702 // break;
44703 // }
44704 //}
44705 //set_register(sarg1, (script_num * 10000));
44706 }
44707 void FFScript::do_getsubscreenscript()
44708 {
44709 //int32_t arrayptr = ri->d[rINDEX]/10000;
44710 //string the_string;
44711 //int32_t script_num = -1;
44712 //ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44713
44714 //for(int32_t q = 0; q < NUMSCRIPTSUBSCREEN; q++)
44715 //{
44716 // if(!(strcmp(the_string.c_str(), subscreenmap[q].scriptname.c_str())))
44717 // {
44718 // script_num = q+1;
44719 // break;
44720 // }
44721 //}
44722 //set_register(sarg1, (script_num * 10000));
44723 set_register(sarg1, 0); //Remove this line, when we add this script type, then un-comment the rest. -Z
44724 }
44725 void FFScript::do_getnpcbyname()
44726 {
44727 int32_t arrayptr = get_register(sarg1) / 10000;
44728 string the_string;
44729 int32_t num = -1;
44730 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44731
44732 for(int32_t q = 0; q < MAXNPCS; q++)
44733 {
44734 if(!(strcmp(the_string.c_str(), guy_string[q])))
44735 {
44736 num = q;
44737 break;
44738 }
44739 }
44740 set_register(sarg1, (num * 10000));
44741 }
44742 void FFScript::do_getitembyname()
44743 {
44744 int32_t arrayptr = get_register(sarg1) / 10000;
44745 string the_string;
44746 int32_t num = -1;
44747 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44748
44749 for(int32_t q = 0; q < MAXNPCS; q++)
44750 {
44751 if(!(strcmp(the_string.c_str(), item_string[q])))
44752 {
44753 num = q;
44754 break;
44755 }
44756 }
44757 set_register(sarg1, (num * 10000));
44758 }
44759 void FFScript::do_getcombobyname()
44760 {
44761 int32_t arrayptr = get_register(sarg1) / 10000;
44762 string the_string;
44763 int32_t num = -1;
44764 ArrayH::getString(arrayptr, the_string, 256);
44765
44766 if (!the_string.empty())
44767 {
44768 for(int32_t q = 0; q < MAXCOMBOS; q++)
44769 {
44770 if (the_string == combobuf[q].label)
44771 {
44772 num = q;
44773 break;
44774 }
44775 }
44776 }
44777 set_register(sarg1, (num * 10000));
44778 }
44779 void FFScript::do_getdmapbyname()
44780 {
44781 int32_t arrayptr = get_register(sarg1) / 10000;
44782 string the_string;
44783 int32_t num = -1;
44784 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
44785
44786 for(int32_t q = 0; q < MAXDMAPS; q++)
44787 {
44788 if(!(strcmp(the_string.c_str(), DMaps[q].name)))
44789 {
44790 num = q;
44791 break;
44792 }
44793 }
44794 set_register(sarg1, (num * 10000));
44795 }
44796
44797 ////////////////////////
44798 /// String Utilities ///
44799 ////////////////////////
44800 void FFScript::do_ConvertCase(const bool v)
44801 {
44802 int32_t arrayptr_a = get_register(sarg1) / 10000;
44803 string strA;
44804 ArrayH::getString(arrayptr_a, strA);
44805 if ( strA.size() < 1 )
44806 {
44807 Z_scripterrlog("String passed to UpperToLower() is too small. Size is: %d \n", strA.size());
44808 set_register(sarg1, 0); return;
44809 }
44810 for ( size_t q = 0; q < strA.size(); ++q )
44811 {
44812 if ( strA[q] < 'a' )
44813 strA[q] += 32 * (strA[q] >= 'A' && strA[q] <= 'Z');
44814
44815 else
44816 strA[q] -= 32 * (strA[q] >= 'a' && strA[q] <= 'z');
44817 //strA[q] -= (32 * (strA[q] >= 'a' && strA[q] <= 'z')) * (-1*((strA[q] >= 'A' && strA[q] <= 'Z')));
44818 //int32_t n = 'c';
44819
44820 //strA[q] -= 32 * ((strA[q] >= 'a' && strA[q] <= 'z')) * (-1*((strA[q] >= 'A' && strA[q] <= 'Z')));
44821 //zprint2("n is %d\n", n);
44822 //if(( strA[q] >= 'a' || strA[q] <= 'z' ) || ( strA[q] >= 'A' || strA[q] <= 'Z' ))
44823 //{
44824 // if ( strA[q] < 'a' ) { strA[q] += 32; }
44825 // else strA[q] -= 32;
44826 // continue;
44827 //}
44828
44829 }
44830 //zprint("Converted string is: %s \n", strA.c_str());
44831 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
44832 {
44833 Z_scripterrlog("Dest string supplied to 'LowerToUpper()' not large enough\n");
44834 set_register(sarg1, 0);
44835 }
44836 else set_register(sarg1, (10000));
44837 }
44838
44839 void FFScript::do_xlen(const bool v)
44840 {
44841 //not implemented, xlen not found
44842 //zprint("Running: %s\n","strlen()");
44843 int32_t arrayptr = (SH::get_arg(sarg2, v) / 10000);
44844 string str;
44845 ArrayH::getString(arrayptr, str);
44846 //zprint("strlen string size is: %d\n", str.length());
44847 //set_register(sarg1, (xlen(str.c_str()) * 10000));
44848 }
44849
44850 void FFScript::do_xtoi(const bool v)
44851 {
44852 int32_t arrayptr = (SH::get_arg(sarg2, v) / 10000);
44853 string str;
44854 ArrayH::getString(arrayptr, str);
44855 //zprint2("xtoi array pointer is: %d\n", arrayptr);
44856 //zprint2("xtoi string is %s\n", str.c_str());
44857 double val = zc_xtoi(const_cast<char*>(str.c_str()));
44858 //zprint2("xtoi val is %f\n", val);
44859 set_register(sarg1, (int32_t)(val) * 10000);
44860 }
44861 void FFScript::do_xtoi2()
44862 {
44863 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
44864 string strA;
44865 ArrayH::getString(arrayptr_a, strA);
44866 set_register(sarg1, (zc_xtoi(strA.c_str()) * 10000));
44867 }
44868
44869 // Calculates log2 of number.
44870 double FFScript::Log2( double n )
44871 {
44872 // log(n)/log(2) is log2.
44873 return log( (double)n ) / log( (double)2 );
44874 }
44875
44876 //xtoa, convert hex number to hex ascii
44877 void FFScript::do_xtoa()
44878 {
44879
44880 int32_t arrayptr_a = get_register(sarg1) / 10000;
44881 int32_t number = get_register(sarg2) / 10000;//ri->d[rEXP2]/10000; //why are you not in sarg2?!!
44882
44883 //for ( int32_t q = 0; q < 6; ++q )
44884 // zprint2("ri->d[%d] is %d", q, ri->d[q]);
44885
44886 // zprint2("xtoa_c arrayptr_a is: %d\n",arrayptr_a);
44887 // zprint2("xtoa_c number is: %d\n",number);
44888
44889
44890
44891
44892 bool isneg = false;
44893 if ( number < 0 )
44894 {
44895 isneg = true;
44896 number *= -1;
44897 }
44898 double num = number;
44899 // zprint2("xtoa_c(), num is: %f\n", num);
44900 int32_t digits = num ? floor(FFCore.LogToBase(num, 16) + 1) : 1;
44901 //sizeof(number)*CHAR_BIT/4;
44902 // zprint2("xtoa_c, digits is: %d\n",digits);
44903
44904
44905 int32_t pos = 0;
44906 string strA;
44907 if(number == 0) //Needs to precede str.resize(digits+3) as if the number is <= 0 then this breaks.
44908 {
44909 strA.resize(3);
44910 strA[pos+2] = '0';
44911 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
44912 {
44913 Z_scripterrlog("Dest string supplied to 'itoa()' not large enough\n");
44914 set_register(sarg1, 0);
44915 }
44916 else set_register(sarg1, 30000); //returns the pointer to the dest
44917 return;
44918 }
44919 int32_t ret = 0;
44920 strA.resize(digits+3+(isneg?1:0));
44921 //num = Floor(Abs(num));
44922 if ( isneg )
44923 {
44924 strA[pos] = '-';
44925 strA[pos+1] = '0';
44926 strA[pos+2] = 'x';
44927 ret = 3;
44928 }
44929 else
44930 {
44931 strA[pos] = '0';
44932 strA[pos+1] = 'x';
44933 ret = 2;
44934 }
44935
44936 int32_t alphaoffset = 'A' - 0xA;
44937 for(int32_t i = 0; i < digits; ++i)
44938 {
44939 int32_t coeff = ((int32_t)floor((double)(((double)number) / pow((float)0x10, digits - i - 1))) % 0x10);
44940 strA[pos + ret + i] = coeff < 0xA ? coeff + '0' : coeff + alphaoffset;
44941 }
44942 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
44943 {
44944 Z_scripterrlog("Dest string supplied to 'xtoa()' not large enough\n");
44945 set_register(sarg1, 0);
44946 }
44947 //set_register(sarg1, (strcat((char)strA.c_str(), strB.c_str()) * 10000));
44948 else set_register(sarg1, (ret + digits -(isneg?1:0))*10000); //don't count the - sign as a digit
44949 }
44950
44951 void FFScript::do_ilen(const bool v)
44952 {
44953 int32_t arrayptr = (SH::get_arg(sarg2, v) / 10000);
44954 string str;
44955 ArrayH::getString(arrayptr, str);
44956 //zprint("strlen string size is: %d\n", str.length());
44957 set_register(sarg1, (FFCore.ilen((char*)str.c_str()) * 10000));
44958 }
44959
44960 //! Note atoi2 (atoi(str, len) can be accompished with str.resize after getString.
44961 void FFScript::do_atoi(const bool v)
44962 {
44963 int32_t arrayptr = (SH::get_arg(sarg2, v) / 10000);
44964 string str;
44965 ArrayH::getString(arrayptr, str);
44966 set_register(sarg1, (atoi(str.c_str()) * 10000));
44967 }
44968
44969 void FFScript::do_strstr()
44970 {
44971
44972 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
44973 int32_t arrayptr_b = ri->d[rINDEX2]/10000; //get_register(sarg2) / 10000?
44974 string strA;
44975 string strB;
44976 ArrayH::getString(arrayptr_a, strA);
44977 ArrayH::getString(arrayptr_b, strB);
44978 if ( strA.size() < 1 )
44979 {
44980 Z_scripterrlog("String passed to strstr() is too small. Size is: %d \n", strA.size());
44981 set_register(sarg1,-10000);
44982 return;
44983 }
44984 set_register(sarg1, (strA.find(strB) * 10000));
44985 }
44986
44987 void FFScript::do_strcat()
44988 {
44989
44990 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
44991 int32_t arrayptr_b = ri->d[rINDEX2]/10000; //get_register(sarg2) / 10000?
44992 string strA;
44993 string strB;
44994 ArrayH::getString(arrayptr_a, strA);
44995 ArrayH::getString(arrayptr_b, strB);
44996 //char str_c[2048];
44997 //strcpy(str_c, strA.c_str());
44998 string strC = strA + strB;
44999 //zprint("strcat string: %s\n", strC.c_str());
45000 if(ArrayH::setArray(arrayptr_a, strC) == SH::_Overflow)
45001 {
45002 Z_scripterrlog("Dest string supplied to 'strcat()' not large enough\n");
45003 set_register(sarg1, 0);
45004 }
45005 //set_register(sarg1, (strcat((char)strA.c_str(), strB.c_str()) * 10000));
45006 else set_register(sarg1, arrayptr_a); //returns the pointer to the dest
45007 }
45008 void FFScript::do_strspn()
45009 {
45010
45011 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
45012 int32_t arrayptr_b = ri->d[rINDEX2]/10000; //get_register(sarg2) / 10000?
45013 string strA;
45014 string strB;
45015 ArrayH::getString(arrayptr_a, strA);
45016 ArrayH::getString(arrayptr_b, strB);
45017 set_register(sarg1, (strspn(strA.c_str(), strB.c_str()) * 10000));
45018 }
45019
45020 void FFScript::do_strcspn()
45021 {
45022
45023 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
45024 int32_t arrayptr_b = ri->d[rINDEX2]/10000;
45025 string strA;
45026 string strB;
45027 ArrayH::getString(arrayptr_a, strA);
45028 ArrayH::getString(arrayptr_b, strB);
45029 set_register(sarg1, (strcspn(strA.c_str(), strB.c_str()) * 10000));
45030 }
45031
45032 void FFScript::do_strchr()
45033 {
45034
45035 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
45036 char chr_to_find = (ri->d[rINDEX2]/10000);
45037 string strA;
45038 ArrayH::getString(arrayptr_a, strA);
45039 if ( strA.size() < 1 )
45040 {
45041 Z_scripterrlog("String passed to strchr() is too small. Size is: %d \n", strA.size());
45042 set_register(sarg1,-10000);
45043 return;
45044 }
45045
45046 set_register(sarg1,strA.find_first_of(chr_to_find)*10000);
45047 }
45048 void FFScript::do_strrchr()
45049 {
45050 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
45051 char chr_to_find = (ri->d[rINDEX2]/10000);
45052 string strA;
45053 ArrayH::getString(arrayptr_a, strA);
45054 if ( strA.size() < 1 )
45055 {
45056 Z_scripterrlog("String passed to strrchr() is too small. Size is: %d \n", strA.size());
45057 set_register(sarg1,-10000);
45058 return;
45059 }
45060 set_register(sarg1,strA.find_last_of(chr_to_find)*10000);
45061 }
45062
45063 void FFScript::do_remchr2()
45064 {
45065 //Not implemented, remchr not found
45066 //not part of any standard library
45067 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
45068 string strA;
45069 ArrayH::getString(arrayptr_a, strA);
45070 //set_register(sarg1, (remchr(strA.c_str(), (ri->d[rINDEX2]/10000)) * 10000));
45071 }
45072 //Bookmark
45073 void FFScript::do_atoi2()
45074 {
45075 //not implemented; atoi does not take 2 params
45076 int32_t arrayptr_a = ri->d[rINDEX]/10000;
45077 string strA;
45078 ArrayH::getString(arrayptr_a, strA);
45079 //set_register(sarg1, (atoi(strA.c_str(), (ri->d[rINDEX2]/10000)) * 10000));
45080 }
45081 void FFScript::do_ilen2()
45082 {
45083 //not implemented, ilen not found
45084 int32_t arrayptr_a = ri->d[rINDEX]/10000;
45085 string strA;
45086 ArrayH::getString(arrayptr_a, strA);
45087 //set_register(sarg1, (ilen(strA.c_str(), (ri->d[rINDEX2]/10000)) * 10000));
45088 }
45089 void FFScript::do_xlen2()
45090 {
45091 //not implemented, xlen not found
45092 int32_t arrayptr_a = ri->d[rINDEX]/10000;
45093 string strA;
45094 ArrayH::getString(arrayptr_a, strA);
45095 //set_register(sarg1, (xlen(strA.c_str(), (ri->d[rINDEX2]/10000)) * 10000));
45096 }
45097
45098 4761 void FFScript::do_itoa()
45099 {
45100 4761 int32_t arrayptr_a = get_register(sarg1) / 10000;
45101 4761 int32_t number = get_register(sarg2) / 10000;
45102
45103 char buf[16];
45104 4761 zc_itoa(number, buf, 10);
45105 4761 int32_t ret = ::strlen(buf) * 10000L;
45106
1/2
✓ Branch 0 taken 4761 times.
✗ Branch 1 not taken.
4761 string strA(buf);
45107
45108
2/4
✓ Branch 0 taken 4761 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4761 times.
4761 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
45109 {
45110 Z_scripterrlog("Dest string supplied to 'itoa()' not large enough\n");
45111 set_register(sarg1, -1);
45112 }
45113
1/2
✓ Branch 0 taken 4761 times.
✗ Branch 1 not taken.
4761 else set_register(sarg1, ret); //returns the number of digits used
45114 4761 }
45115
45116 void FFScript::do_itoacat()
45117 {
45118
45119 int32_t arrayptr_a = get_register(sarg1) / 10000;
45120 int32_t number = get_register(sarg2) / 10000;
45121
45122 // zprint2("itoacat arrayptr_a is: %d\n",arrayptr_a);
45123 // zprint2("itoacat number is: %d\n",number);
45124
45125 double num = number;
45126 int32_t digits = FFCore.numDigits(number); //int32_t(log10(temp) * 10000.0)
45127 // zprint2("itoacat, digits is: %d\n",digits);
45128 int32_t pos = 0;
45129 int32_t ret = 0;
45130 string strA;
45131 string strB;
45132 strB.resize(digits);
45133 ArrayH::getString(arrayptr_a, strA);
45134 if(num < 0)
45135 {
45136 strB.resize(digits+1);
45137 strB[pos] = '-';
45138 ++ret;
45139 num = -num;
45140 }
45141 else if(num == 0)
45142 {
45143 strB[pos] = '0';
45144 string strC = strA + strB;
45145 if(ArrayH::setArray(arrayptr_a, strC) == SH::_Overflow)
45146 {
45147 Z_scripterrlog("Dest string supplied to 'itoacat()' not large enough\n");
45148 set_register(sarg1, 0);
45149 }
45150 else set_register(sarg1, arrayptr_a); //returns the pointer to the dest
45151 return;
45152 }
45153
45154
45155 for(int32_t i = 0; i < digits; ++i)
45156 strB[pos + ret + i] = ((int32_t)floor((double)(num / pow((float)10, digits - i - 1))) % 10) + '0';
45157
45158 string strC = strA + strB;
45159 if(ArrayH::setArray(arrayptr_a, strC) == SH::_Overflow)
45160 {
45161 Z_scripterrlog("Dest string supplied to 'itoacat()' not large enough\n");
45162 set_register(sarg1, 0);
45163 }
45164 //set_register(sarg1, (strcat((char)strB.c_str(), strB.c_str()) * 10000));
45165 else set_register(sarg1, arrayptr_a); //returns the pointer to the dest
45166 }
45167
45168 /*
45169 void FFScript::do_itoa()
45170 {
45171
45172 int32_t arrayptr_a = ri->d[rINDEX2]/10000;
45173 int32_t value = ri->d[rINDEX]/10000;
45174 char the_string[13];
45175 char* chrptr = NULL;
45176 chrptr = zc_itoa(value, the_string, 10);
45177 //Returns the number of characters used.
45178 if(ArrayH::setArray(arrayptr_a, the_string) == SH::_Overflow)
45179 Z_scripterrlog("Dest string supplied to 'itoa()' not large enough\n");
45180 set_register(sarg1, (FFCore.zc_strlen(the_string)*10000));
45181 }
45182 */
45183
45184 1072 void FFScript::do_strcpy(const bool a, const bool b)
45185 {
45186 1072 int32_t arrayptr_b = SH::get_arg(sarg1, a) / 10000;
45187 1072 int32_t arrayptr_a = SH::get_arg(sarg2, b) / 10000;
45188
45189 1072 string strA;
45190
45191
1/2
✓ Branch 0 taken 1072 times.
✗ Branch 1 not taken.
1072 ArrayH::getString(arrayptr_a, strA);
45192
45193
2/4
✓ Branch 0 taken 1072 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1072 times.
1072 if(ArrayH::setArray(arrayptr_b, strA) == SH::_Overflow)
45194 Z_scripterrlog("Dest string supplied to 'strcpy()' not large enough\n");
45195 1072 }
45196 void FFScript::do_arraycpy(const bool a, const bool b)
45197 {
45198 int32_t arrayptr_dest = SH::get_arg(sarg1, a) / 10000;
45199 int32_t arrayptr_src = SH::get_arg(sarg2, b) / 10000;
45200 ArrayH::copyValues(arrayptr_dest, arrayptr_src, ArrayH::getSize(arrayptr_src));
45201 }
45202 2629 void FFScript::do_strlen(const bool v)
45203 {
45204 //zprint("Running: %s\n","strlen()");
45205 2629 int32_t arrayptr = (SH::get_arg(sarg2, v) / 10000);
45206 2629 string str;
45207
1/2
✓ Branch 0 taken 2629 times.
✗ Branch 1 not taken.
2629 ArrayH::getString(arrayptr, str);
45208 //zprint("strlen string size is: %d\n", str.length());
45209
1/2
✓ Branch 0 taken 2629 times.
✗ Branch 1 not taken.
2629 set_register(sarg1, (str.length() * 10000));
45210 2629 }
45211
45212 void FFScript::do_strncmp()
45213 {
45214 int32_t arrayptr_a = ri->d[rINDEX]/10000;
45215 int32_t arrayptr_b = ri->d[rEXP2]/10000;
45216 int32_t len = ri->d[rEXP1]/10000;
45217 string strA;
45218 string strB;
45219 ArrayH::getString(arrayptr_a, strA);
45220 ArrayH::getString(arrayptr_b, strB);
45221 set_register(sarg1, (strncmp(strA.c_str(), strB.c_str(), len) * 10000));
45222 }
45223
45224 void FFScript::do_strnicmp()
45225 {
45226 int32_t arrayptr_a = ri->d[rINDEX]/10000;
45227 int32_t arrayptr_b = ri->d[rEXP2]/10000;
45228 int32_t len = ri->d[rEXP1]/10000;
45229 string strA;
45230 string strB;
45231 ArrayH::getString(arrayptr_a, strA);
45232 ArrayH::getString(arrayptr_b, strB);
45233 set_register(sarg1, (ustrnicmp(strA.c_str(), strB.c_str(), len) * 10000));
45234 }
45235
45236 void FFScript::do_npc_canmove(const bool v)
45237 {
45238 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
45239 int32_t sz = ArrayH::getSize(arrayptr);
45240 //bool can_mv = false;
45241 if(GuyH::loadNPC(ri->guyref, "npc->CanMove()") == SH::_NoError)
45242 {
45243 ArrayManager am(arrayptr);
45244 if(am.invalid()) return;
45245 if ( sz == 1 ) //bool canmove(int32_t ndir): dir only, uses 'step' IIRC
45246 {
45247 set_register(sarg1, ( GuyH::getNPC()->canmove((am.get(0)/10000),false)) ? 10000 : 0);
45248 }
45249 else if ( sz == 2 ) //bool canmove(int32_t ndir, int32_t special): I think that this also uses the default 'step'
45250 {
45251 set_register(sarg1, ( GuyH::getNPC()->canmove((am.get(0)/10000),(zfix)(am.get(1)/10000), false)) ? 10000 : 0);
45252 }
45253 else if ( sz == 3 ) //bool canmove(int32_t ndir,zfix s,int32_t special) : I'm pretty sure that 'zfix s' is 'step' here.
45254 {
45255 set_register(sarg1, ( GuyH::getNPC()->canmove((am.get(0)/10000),(zfix)(am.get(1)/10000),(am.get(2)/10000),false)) ? 10000 : 0);
45256 }
45257 else if ( sz == 7 ) //bool canmove(int32_t ndir,zfix s,int32_t special) : I'm pretty sure that 'zfix s' is 'step' here.
45258 {
45259 set_register(sarg1, ( GuyH::getNPC()->canmove((am.get(0)/10000),(zfix)(am.get(1)/10000),(am.get(2)/10000),(am.get(3)/10000),(am.get(4)/10000),(am.get(5)/10000),(am.get(6)/10000),false)) ? 10000 : 0);
45260 }
45261 else
45262 {
45263 Z_scripterrlog("Invalid array size (%d) passed to npc->CanMove(). The array size must be [1], [2], [3], or [7].\n", sz);
45264 //can_mv = false;
45265 set_register(sarg1, 0);
45266 }
45267 }
45268 //set_register(sarg1, ( can_mv ? 10000 : 0));
45269 }
45270
45271 //void do_get_enh_music_filename(const bool v)
45272 void FFScript::get_npcdata_initd_label(const bool v)
45273 {
45274 int32_t init_d_index = SH::get_arg(sarg1, v) / 10000;
45275 int32_t arrayptr = get_register(sarg2) / 10000;
45276
45277 if((unsigned)init_d_index > 7)
45278 {
45279 Z_scripterrlog("Invalid InitD[] index (%d) passed to npcdata->GetInitDLabel().\n", init_d_index);
45280 return;
45281 }
45282
45283 if(ArrayH::setArray(arrayptr, string(guysbuf[ri->npcdataref].initD_label[init_d_index])) == SH::_Overflow)
45284 Z_scripterrlog("Array supplied to 'npcdata->GetInitDLabel()' not large enough\n");
45285 }
45286
45287 /////////////////////
45288 /// MATHS HELPERS ///
45289 /////////////////////
45290
45291 //Returns the log of val to the base 10. Any value <= 0 will return 0.
45292 int32_t FFScript::Log10(double temp)
45293 {
45294 int32_t ret = 0;
45295 if(temp > 0)
45296 ret = int32_t(log10(temp) * 10000.0);
45297 else ret = 0;
45298 return ret;
45299 }
45300
45301 //Returns the number of digits in a given integer.
45302 int32_t FFScript::numDigits(int32_t number)
45303 {
45304 int32_t digits = 0;
45305 while (number)
45306 {
45307 number /= 10;
45308 digits++;
45309 }
45310 return digits;
45311 }
45312
45313 // Returns the natural logarithm of val (to the base e). Any value <= 0 will return 0.
45314 double FFScript::ln(double temp)
45315 {
45316
45317 if(temp > 0)
45318 return (log(temp));
45319 else
45320 {
45321 return 0;
45322 }
45323 }
45324
45325 // Returns the logarithm of x to the given base.
45326 double FFScript::LogToBase(double x, double base)
45327 {
45328 if(x <= 0 || base <= 0) return 0;
45329 return FFCore.ln(x)/FFCore.ln(base);
45330 }
45331
45332 script_command ZASMcommands[NUMCOMMANDS+1]=
45333 {
45334 //name args arg1 arg2 more
45335 { "SETV", 2, 0, 1, 0},
45336 { "SETR", 2, 0, 0, 0},
45337 { "ADDR", 2, 0, 0, 0},
45338 { "ADDV", 2, 0, 1, 0},
45339 { "SUBR", 2, 0, 0, 0},
45340 { "SUBV", 2, 0, 1, 0},
45341 { "MULTR", 2, 0, 0, 0},
45342 { "MULTV", 2, 0, 1, 0},
45343 { "DIVR", 2, 0, 0, 0},
45344 { "DIVV", 2, 0, 1, 0},
45345 { "WAITFRAME", 0, 0, 0, 0},
45346 { "GOTO", 1, 1, 0, 0},
45347 { "CHECKTRIG", 0, 0, 0, 0},
45348 { "WARP", 2, 1, 1, 0},
45349 { "COMPARER", 2, 0, 0, 0},
45350 { "COMPAREV", 2, 0, 1, 0},
45351 { "GOTOTRUE", 1, 1, 0, 0},
45352 { "GOTOFALSE", 1, 1, 0, 0},
45353 { "GOTOLESS", 1, 1, 0, 0},
45354 { "GOTOMORE", 1, 1, 0, 0},
45355 { "LOAD1", 2, 0, 0, 0},
45356 { "LOAD2", 2, 0, 0, 0},
45357 { "SETA1", 2, 0, 0, 0},
45358 { "SETA2", 2, 0, 0, 0},
45359 { "QUIT", 0, 0, 0, 0},
45360 { "SINR", 2, 0, 0, 0},
45361 { "SINV", 2, 0, 1, 0},
45362 { "COSR", 2, 0, 0, 0},
45363 { "COSV", 2, 0, 1, 0},
45364 { "TANR", 2, 0, 0, 0},
45365 { "TANV", 2, 0, 1, 0},
45366 { "MODR", 2, 0, 0, 0},
45367 { "MODV", 2, 0, 1, 0},
45368 { "ABS", 1, 0, 0, 0},
45369 { "MINR", 2, 0, 0, 0},
45370 { "MINV", 2, 0, 1, 0},
45371 { "MAXR", 2, 0, 0, 0},
45372 { "MAXV", 2, 0, 1, 0},
45373 { "RNDR", 2, 0, 0, 0},
45374 { "RNDV", 2, 0, 1, 0},
45375 { "FACTORIAL", 1, 0, 0, 0},
45376 { "POWERR", 2, 0, 0, 0},
45377 { "POWERV", 2, 0, 1, 0},
45378 { "IPOWERR", 2, 0, 0, 0},
45379 { "IPOWERV", 2, 0, 1, 0},
45380 { "ANDR", 2, 0, 0, 0},
45381 { "ANDV", 2, 0, 1, 0},
45382 { "ORR", 2, 0, 0, 0},
45383 { "ORV", 2, 0, 1, 0},
45384 { "XORR", 2, 0, 0, 0},
45385 { "XORV", 2, 0, 1, 0},
45386 { "NANDR", 2, 0, 0, 0},
45387 { "NANDV", 2, 0, 1, 0},
45388 { "NORR", 2, 0, 0, 0},
45389 { "NORV", 2, 0, 1, 0},
45390 { "XNORR", 2, 0, 0, 0},
45391 { "XNORV", 2, 0, 1, 0},
45392 { "NOT", 1, 0, 0, 0},
45393 { "LSHIFTR", 2, 0, 0, 0},
45394 { "LSHIFTV", 2, 0, 1, 0},
45395 { "RSHIFTR", 2, 0, 0, 0},
45396 { "RSHIFTV", 2, 0, 1, 0},
45397 { "TRACER", 1, 0, 0, 0},
45398 { "TRACEV", 1, 1, 0, 0},
45399 { "TRACE3", 0, 0, 0, 0},
45400 { "LOOP", 2, 1, 0, 0},
45401 { "PUSHR", 1, 0, 0, 0},
45402 { "PUSHV", 1, 1, 0, 0},
45403 { "POP", 1, 0, 0, 0},
45404 { "ENQUEUER", 2, 0, 0, 0},
45405 { "ENQUEUEV", 2, 0, 1, 0},
45406 { "DEQUEUE", 1, 0, 0, 0},
45407 { "PLAYSOUNDR", 1, 0, 0, 0},
45408 { "PLAYSOUNDV", 1, 1, 0, 0},
45409 { "LOADLWEAPONR", 1, 0, 0, 0},
45410 { "LOADLWEAPONV", 1, 1, 0, 0},
45411 { "LOADITEMR", 1, 0, 0, 0},
45412 { "LOADITEMV", 1, 1, 0, 0},
45413 { "LOADNPCR", 1, 0, 0, 0},
45414 { "LOADNPCV", 1, 1, 0, 0},
45415 { "CREATELWEAPONR", 1, 0, 0, 0},
45416 { "CREATELWEAPONV", 1, 1, 0, 0},
45417 { "CREATEITEMR", 1, 0, 0, 0},
45418 { "CREATEITEMV", 1, 1, 0, 0},
45419 { "CREATENPCR", 1, 0, 0, 0},
45420 { "CREATENPCV", 1, 1, 0, 0},
45421 { "LOADI", 2, 0, 0, 0},
45422 { "STOREI", 2, 0, 0, 0},
45423 { "GOTOR", 1, 0, 0, 0},
45424 { "SQROOTV", 2, 0, 1, 0},
45425 { "SQROOTR", 2, 0, 0, 0},
45426 { "CREATEEWEAPONR", 1, 0, 0, 0},
45427 { "CREATEEWEAPONV", 1, 1, 0, 0},
45428 { "PITWARP", 2, 1, 1, 0},
45429 { "WARPR", 2, 0, 0, 0},
45430 { "PITWARPR", 2, 0, 0, 0},
45431 { "CLEARSPRITESR", 1, 0, 0, 0},
45432 { "CLEARSPRITESV", 1, 1, 0, 0},
45433 { "RECT", 0, 0, 0, 0},
45434 { "CIRCLE", 0, 0, 0, 0},
45435 { "ARC", 0, 0, 0, 0},
45436 { "ELLIPSE", 0, 0, 0, 0},
45437 { "LINE", 0, 0, 0, 0},
45438 { "PUTPIXEL", 0, 0, 0, 0},
45439 { "DRAWTILE", 0, 0, 0, 0},
45440 { "DRAWCOMBO", 0, 0, 0, 0},
45441 { "ELLIPSE2", 0, 0, 0, 0},
45442 { "SPLINE", 0, 0, 0, 0},
45443 { "FLOODFILL", 0, 0, 0, 0},
45444 { "COMPOUNDR", 1, 0, 0, 0},
45445 { "COMPOUNDV", 1, 1, 0, 0},
45446 { "MSGSTRR", 1, 0, 0, 0},
45447 { "MSGSTRV", 1, 1, 0, 0},
45448 { "ISVALIDITEM", 1, 0, 0, 0},
45449 { "ISVALIDNPC", 1, 0, 0, 0},
45450 { "PLAYMIDIR", 1, 0, 0, 0},
45451 { "PLAYMIDIV", 1, 1, 0, 0},
45452 { "COPYTILEVV", 2, 1, 1, 0},
45453 { "COPYTILEVR", 2, 1, 0, 0},
45454 { "COPYTILERV", 2, 0, 1, 0},
45455 { "COPYTILERR", 2, 0, 0, 0},
45456 { "SWAPTILEVV", 2, 1, 1, 0},
45457 { "SWAPTILEVR", 2, 1, 0, 0},
45458 { "SWAPTILERV", 2, 0, 1, 0},
45459 { "SWAPTILERR", 2, 0, 0, 0},
45460 { "CLEARTILEV", 1, 1, 0, 0},
45461 { "CLEARTILER", 1, 0, 0, 0},
45462 { "OVERLAYTILEVV", 2, 1, 1, 0},
45463 { "OVERLAYTILEVR", 2, 1, 0, 0},
45464 { "OVERLAYTILERV", 2, 0, 1, 0},
45465 { "OVERLAYTILERR", 2, 0, 0, 0},
45466 { "FLIPROTTILEVV", 2, 1, 1, 0},
45467 { "FLIPROTTILEVR", 2, 1, 0, 0},
45468 { "FLIPROTTILERV", 2, 0, 1, 0},
45469 { "FLIPROTTILERR", 2, 0, 0, 0},
45470 { "GETTILEPIXELV", 1, 1, 0, 0},
45471 { "GETTILEPIXELR", 1, 0, 0, 0},
45472 { "SETTILEPIXELV", 1, 1, 0, 0},
45473 { "SETTILEPIXELR", 1, 0, 0, 0},
45474 { "SHIFTTILEVV", 2, 1, 1, 0},
45475 { "SHIFTTILEVR", 2, 1, 0, 0},
45476 { "SHIFTTILERV", 2, 0, 1, 0},
45477 { "SHIFTTILERR", 2, 0, 0, 0},
45478 { "ISVALIDLWPN", 1, 0, 0, 0},
45479 { "ISVALIDEWPN", 1, 0, 0, 0},
45480 { "LOADEWEAPONR", 1, 0, 0, 0},
45481 { "LOADEWEAPONV", 1, 1, 0, 0},
45482 { "ALLOCATEMEMR", 2, 0, 0, 0},
45483 { "ALLOCATEMEMV", 2, 0, 1, 0},
45484 { "ALLOCATEGMEMV", 2, 0, 1, 0},
45485 { "DEALLOCATEMEMR", 1, 0, 0, 0},
45486 { "DEALLOCATEMEMV", 1, 1, 0, 0},
45487 { "WAITDRAW", 0, 0, 0, 0},
45488 { "ARCTANR", 1, 0, 0, 0},
45489 { "LWPNUSESPRITER", 1, 0, 0, 0},
45490 { "LWPNUSESPRITEV", 1, 1, 0, 0},
45491 { "EWPNUSESPRITER", 1, 0, 0, 0},
45492 { "EWPNUSESPRITEV", 1, 1, 0, 0},
45493 { "LOADITEMDATAR", 1, 0, 0, 0},
45494 { "LOADITEMDATAV", 1, 1, 0, 0},
45495 { "BITNOT", 1, 0, 0, 0},
45496 { "LOG10", 1, 0, 0, 0},
45497 { "LOGE", 1, 0, 0, 0},
45498 { "ISSOLID", 1, 0, 0, 0},
45499 { "LAYERSCREEN", 2, 0, 0, 0},
45500 { "LAYERMAP", 2, 0, 0, 0},
45501 { "TRACE2R", 1, 0, 0, 0},
45502 { "TRACE2V", 1, 1, 0, 0},
45503 { "TRACE4", 0, 0, 0, 0},
45504 { "TRACE5", 0, 0, 0, 0},
45505 { "SECRETS", 0, 0, 0, 0},
45506 { "DRAWCHAR", 0, 0, 0, 0},
45507 { "GETSCREENFLAGS", 1, 0, 0, 0},
45508 { "QUAD", 0, 0, 0, 0},
45509 { "TRIANGLE", 0, 0, 0, 0},
45510 { "ARCSINR", 2, 0, 0, 0},
45511 { "ARCSINV", 2, 1, 0, 0},
45512 { "ARCCOSR", 2, 0, 0, 0},
45513 { "ARCCOSV", 2, 1, 0, 0},
45514 { "GAMEEND", 0, 0, 0, 0},
45515 { "DRAWINT", 0, 0, 0, 0},
45516 { "SETTRUE", 1, 0, 0, 0},
45517 { "SETFALSE", 1, 0, 0, 0},
45518 { "SETMORE", 1, 0, 0, 0},
45519 { "SETLESS", 1, 0, 0, 0},
45520 { "FASTTILE", 0, 0, 0, 0},
45521 { "FASTCOMBO", 0, 0, 0, 0},
45522 { "DRAWSTRING", 0, 0, 0, 0},
45523 { "SETSIDEWARP", 0, 0, 0, 0},
45524 { "SAVE", 0, 0, 0, 0},
45525 { "TRACE6", 0, 0, 0, 0},
45526 { "DEPRECATED", 1, 0, 0, 0},
45527 { "QUAD3D", 0, 0, 0, 0},
45528 { "TRIANGLE3D", 0, 0, 0, 0},
45529 { "SETCOLORB", 0, 0, 0, 0},
45530 { "SETDEPTHB", 0, 0, 0, 0},
45531 { "GETCOLORB", 0, 0, 0, 0},
45532 { "GETDEPTHB", 0, 0, 0, 0},
45533 { "COMBOTILE", 2, 0, 0, 0},
45534 { "SETTILEWARP", 0, 0, 0, 0},
45535 { "GETSCREENEFLAGS", 1, 0, 0, 0},
45536 { "GETSAVENAME", 1, 0, 0, 0},
45537 { "ARRAYSIZE", 1, 0, 0, 0},
45538 { "ITEMNAME", 1, 0, 0, 0},
45539 { "SETSAVENAME", 1, 0, 0, 0},
45540 { "NPCNAME", 1, 0, 0, 0},
45541 { "GETMESSAGE", 2, 0, 0, 0},
45542 { "GETDMAPNAME", 2, 0, 0, 0},
45543 { "GETDMAPTITLE", 2, 0, 0, 0},
45544 { "GETDMAPINTRO", 2, 0, 0, 0},
45545 { "ALLOCATEGMEMR", 2, 0, 0, 0},
45546 { "DRAWBITMAP", 0, 0, 0, 0},
45547 { "SETRENDERTARGET", 0, 0, 0, 0},
45548 { "PLAYENHMUSIC", 2, 0, 0, 0},
45549 { "GETMUSICFILE", 2, 0, 0, 0},
45550 { "GETMUSICTRACK", 1, 0, 0, 0},
45551 { "SETDMAPENHMUSIC", 0, 0, 0, 0},
45552 { "DRAWLAYER", 0, 0, 0, 0},
45553 { "DRAWSCREEN", 0, 0, 0, 0},
45554 { "BREAKSHIELD", 1, 0, 0, 0},
45555 { "SAVESCREEN", 1, 0, 0, 0},
45556 { "SAVEQUITSCREEN", 0, 0, 0, 0},
45557 { "SELECTAWPNR", 1, 0, 0, 0},
45558 { "SELECTAWPNV", 1, 1, 0, 0},
45559 { "SELECTBWPNR", 1, 0, 0, 0},
45560 { "SELECTBWPNV", 1, 1, 0, 0},
45561 { "GETSIDEWARPDMAP", 1, 0, 0, 0},
45562 { "GETSIDEWARPSCR", 1, 0, 0, 0},
45563 { "GETSIDEWARPTYPE", 1, 0, 0, 0},
45564 { "GETTILEWARPDMAP", 1, 0, 0, 0},
45565 { "GETTILEWARPSCR", 1, 0, 0, 0},
45566 { "GETTILEWARPTYPE", 1, 0, 0, 0},
45567 { "GETFFCSCRIPT", 1, 0, 0, 0},
45568 { "BITMAPEXR", 0, 0, 0, 0},
45569 { "__RESERVED_FOR_QUAD2R", 0, 0, 0, 0},
45570 { "WAVYIN", 0, 0, 0, 0},
45571 { "WAVYOUT", 0, 0, 0, 0},
45572 { "ZAPIN", 0, 0, 0, 0},
45573 { "ZAPOUT", 0, 0, 0, 0},
45574 { "OPENWIPE", 0, 0, 0, 0},
45575 { "FREE0x00F1", 0, 0, 0, 0 },
45576 { "FREE0x00F2", 0, 0, 0, 0},
45577 { "FREE0x00F3", 0, 0, 0,0},
45578 { "SETMESSAGE", 2, 0, 0, 0},
45579 { "SETDMAPNAME", 2, 0, 0, 0},
45580 { "SETDMAPTITLE", 2, 0, 0, 0},
45581 { "SETDMAPINTRO", 2, 0, 0, 0},
45582 { "GREYSCALEON", 0, 0, 0, 0},
45583 { "GREYSCALEOFF", 0, 0, 0, 0},
45584 { "ENDSOUNDR", 1, 0, 0, 0},
45585 { "ENDSOUNDV", 1, 1, 0, 0},
45586 { "PAUSESOUNDR", 1, 0, 0, 0},
45587 { "PAUSESOUNDV", 1, 1, 0, 0},
45588 { "RESUMESOUNDR", 1, 0, 0, 0},
45589 { "RESUMESOUNDV", 1, 1, 0, 0},
45590 { "PAUSEMUSIC", 0, 0, 0, 0},
45591 { "RESUMEMUSIC", 0, 0, 0, 0},
45592 { "LWPNARRPTR", 1, 0, 0, 0},
45593 { "EWPNARRPTR", 1, 0, 0, 0},
45594 { "EWPNARRPTR", 1, 0, 0, 0},
45595 { "IDATAARRPTR", 1, 0, 0, 0},
45596 { "FFCARRPTR", 1, 0, 0, 0},
45597 { "BOOLARRPTR", 1, 0, 0, 0},
45598 { "BOOLARRPTR", 1, 0, 0, 0},
45599 { "LWPNARRPTR2", 1, 0, 0, 0},
45600 { "EWPNARRPTR2", 1, 0, 0, 0},
45601 { "ITEMARRPTR2", 1, 0, 0, 0},
45602 { "IDATAARRPTR2", 1, 0, 0, 0},
45603 { "FFCARRPTR2", 1, 0, 0, 0},
45604 { "BOOLARRPTR2", 1, 0, 0, 0},
45605 { "NPCARRPTR2", 1, 0, 0, 0},
45606 { "ARRAYSIZEB", 1, 0, 0, 0},
45607 { "ARRAYSIZEF", 1, 0, 0, 0},
45608 { "ARRAYSIZEN", 1, 0, 0, 0},
45609 { "ARRAYSIZEL", 1, 0, 0, 0},
45610 { "ARRAYSIZEE", 1, 0, 0, 0},
45611 { "ARRAYSIZEI", 1, 0, 0, 0},
45612 { "ARRAYSIZEID", 1, 0, 0, 0},
45613 { "POLYGONR", 0, 0, 0, 0},
45614 { "__RESERVED_FOR_POLYGON3DR", 0, 0, 0, 0},
45615 { "__RESERVED_FOR_SETRENDERSOURCE", 0, 0, 0, 0},
45616 { "LINESARRAY", 0, 0, 0, 0},
45617 { "PIXELARRAYR", 0, 0, 0, 0},
45618 { "TILEARRAYR", 0, 0, 0, 0},
45619 { "COMBOARRAYR", 0, 0, 0, 0},
45620 { "RES0000", 0, 0, 0, 0},
45621 { "RES0001", 0, 0, 0, 0},
45622 { "RES0002", 0, 0, 0, 0},
45623 { "RES0003", 0, 0, 0, 0},
45624 { "RES0004", 0, 0, 0, 0},
45625 { "RES0005", 0, 0, 0, 0},
45626 { "RES0006", 0, 0, 0, 0},
45627 { "RES0007", 0, 0, 0, 0},
45628 { "RES0008", 0, 0, 0, 0},
45629 { "RES0009", 0, 0, 0, 0},
45630 { "RES000A", 0, 0, 0, 0},
45631 { "RES000B", 0, 0, 0, 0},
45632 { "RES000C", 0, 0, 0, 0},
45633 { "RES000D", 0, 0, 0, 0},
45634 { "RES000E", 0, 0, 0, 0},
45635 { "RES000F", 0, 0, 0, 0},
45636 { "__RESERVED_FOR_CREATELWPN2VV", 2, 1, 1, 0},
45637 { "__RESERVED_FOR_CREATELWPN2VR", 2, 1, 0, 0},
45638 { "__RESERVED_FOR_CREATELWPN2RV", 2, 0, 1, 0},
45639 { "__RESERVED_FOR_CREATELWPN2RR", 2, 0, 0, 0},
45640 { "GETSCREENDOOR", 1, 0, 0, 0},
45641 { "GETSCREENENEMY", 1, 0, 0, 0},
45642 { "PAUSESFX", 1, 0, 0, 0},
45643 { "RESUMESFX", 1, 0, 0, 0},
45644 { "CONTINUESFX", 1, 0, 0, 0},
45645 { "ADJUSTSFX", 0, 0, 0, 0},
45646 { "GETITEMSCRIPT", 1, 0, 0, 0},
45647 { "GETSCREENLAYOP", 1, 0, 0, 0},
45648 { "GETSCREENSECCMB", 1, 0, 0, 0},
45649 { "GETSCREENSECCST", 1, 0, 0, 0},
45650 { "GETSCREENSECFLG", 1, 0, 0, 0},
45651 { "GETSCREENLAYMAP", 1, 0, 0, 0},
45652 { "GETSCREENLAYSCR", 1, 0, 0, 0},
45653 { "GETSCREENPATH", 1, 0, 0, 0},
45654 { "GETSCREENWARPRX", 1, 0, 0, 0},
45655 { "GETSCREENWARPRY", 1, 0, 0, 0},
45656 { "TRIGGERSECRETR", 1, 0, 0, 0},
45657 { "TRIGGERSECRETV", 1, 1, 0, 0},
45658 { "NIL_UNUSED_1", 1, 0, 0, 0},
45659 { "NIL_UNUSED_2", 1, 1, 0, 0},
45660 //NPCData
45661 //one input, one return
45662 { "GETNPCDATAFLAGS", 2, 0, 0, 0},
45663 { "GETNPCDATAFLAGS2", 2, 0, 0, 0},
45664 { "GETNPCDATAWIDTH", 2, 0, 0, 0},
45665 { "GETNPCDATAHEIGHT", 2, 0, 0, 0},
45666 { "GETNPCDATASTILE", 2, 0, 0, 0},
45667 { "GETNPCDATASWIDTH", 2, 0, 0, 0},
45668 { "GETNPCDATASHEIGHT", 2, 0, 0, 0},
45669 { "GETNPCDATAETILE", 2, 0, 0, 0},
45670 { "GETNPCDATAEWIDTH", 2, 0, 0, 0},
45671 { "GETNPCDATAHP", 2, 0, 0, 0},
45672 { "GETNPCDATAFAMILY", 2, 0, 0, 0},
45673 { "GETNPCDATACSET", 2, 0, 0, 0},
45674 { "GETNPCDATAANIM", 2, 0, 0, 0},
45675 { "GETNPCDATAEANIM", 2, 0, 0, 0},
45676 { "GETNPCDATAFRAMERATE", 2, 0, 0, 0},
45677 { "GETNPCDATAEFRAMERATE", 2, 0, 0, 0},
45678 { "GETNPCDATATOUCHDMG", 2, 0, 0, 0},
45679 { "GETNPCDATAWPNDAMAGE", 2, 0, 0, 0},
45680 { "GETNPCDATAWEAPON", 2, 0, 0, 0},
45681 { "GETNPCDATARANDOM", 2, 0, 0, 0},
45682 { "GETNPCDATAHALT", 2, 0, 0, 0},
45683 { "GETNPCDATASTEP", 2, 0, 0, 0},
45684 { "GETNPCDATAHOMING", 2, 0, 0, 0},
45685 { "GETNPCDATAHUNGER", 2, 0, 0, 0},
45686 { "GETNPCDATADROPSET", 2, 0, 0, 0},
45687 { "GETNPCDATABGSFX", 2, 0, 0, 0},
45688 { "GETNPCDATADEATHSFX", 2, 0, 0, 0},
45689 { "GETNPCDATAXOFS", 2, 0, 0, 0},
45690 { "GETNPCDATAYOFS", 2, 0, 0, 0},
45691 { "GETNPCDATAZOFS", 2, 0, 0, 0},
45692 { "GETNPCDATAHXOFS", 2, 0, 0, 0},
45693 { "GETNPCDATAHYOFS", 2, 0, 0, 0},
45694 { "GETNPCDATAHITWIDTH", 2, 0, 0, 0},
45695 { "GETNPCDATAHITHEIGHT", 2, 0, 0, 0},
45696 { "GETNPCDATAHITZ", 2, 0, 0, 0},
45697 { "GETNPCDATATILEWIDTH", 2, 0, 0, 0},
45698 { "GETNPCDATATILEHEIGHT", 2, 0, 0, 0},
45699 { "GETNPCDATAWPNSPRITE", 2, 0, 0, 0},
45700 //two inputs one return
45701 { "GETNPCDATASCRIPTDEF", 1, 0, 0, 0},
45702 { "GETNPCDATADEFENSE", 1, 0, 0, 0},
45703 { "GETNPCDATASIZEFLAG", 1, 0, 0, 0},
45704 { "GETNPCDATAATTRIBUTE", 1, 0, 0, 0},
45705 //two inputs no return
45706 { "SETNPCDATAFLAGS", 2, 0, 0, 0},
45707 { "SETNPCDATAFLAGS2", 2, 0, 0, 0},
45708 { "SETNPCDATAWIDTH", 2, 0, 0, 0},
45709 { "SETNPCDATAHEIGHT", 2, 0, 0, 0},
45710 { "SETNPCDATASTILE", 2, 0, 0, 0},
45711 { "SETNPCDATASWIDTH", 2, 0, 0, 0},
45712 { "SETNPCDATASHEIGHT", 2, 0, 0, 0},
45713 { "SETNPCDATAETILE", 2, 0, 0, 0},
45714 { "SETNPCDATAEWIDTH", 2, 0, 0, 0},
45715 { "SETNPCDATAHP", 2, 0, 0, 0},
45716 { "SETNPCDATAFAMILY", 2, 0, 0, 0},
45717 { "SETNPCDATACSET", 2, 0, 0, 0},
45718 { "SETNPCDATAANIM", 2, 0, 0, 0},
45719 { "SETNPCDATAEANIM", 2, 0, 0, 0},
45720 { "SETNPCDATAFRAMERATE", 2, 0, 0, 0},
45721 { "SETNPCDATAEFRAMERATE", 2, 0, 0, 0},
45722 { "SETNPCDATATOUCHDMG", 2, 0, 0, 0},
45723 { "SETNPCDATAWPNDAMAGE", 2, 0, 0, 0},
45724 { "SETNPCDATAWEAPON", 2, 0, 0, 0},
45725 { "SETNPCDATARANDOM", 2, 0, 0, 0},
45726 { "SETNPCDATAHALT", 2, 0, 0, 0},
45727 { "SETNPCDATASTEP", 2, 0, 0, 0},
45728 { "SETNPCDATAHOMING", 2, 0, 0, 0},
45729 { "SETNPCDATAHUNGER", 2, 0, 0, 0},
45730 { "SETNPCDATADROPSET", 2, 0, 0, 0},
45731 { "SETNPCDATABGSFX", 2, 0, 0, 0},
45732 { "SETNPCDATADEATHSFX", 2, 0, 0, 0},
45733 { "SETNPCDATAXOFS", 2, 0, 0, 0},
45734 { "SETNPCDATAYOFS", 2, 0, 0, 0},
45735 { "SETNPCDATAZOFS", 2, 0, 0, 0},
45736 { "SETNPCDATAHXOFS", 2, 0, 0, 0},
45737 { "SETNPCDATAHYOFS", 2, 0, 0, 0},
45738 { "SETNPCDATAHITWIDTH", 2, 0, 0, 0},
45739 { "SETNPCDATAHITHEIGHT", 2, 0, 0, 0},
45740 { "SETNPCDATAHITZ", 2, 0, 0, 0},
45741 { "SETNPCDATATILEWIDTH", 2, 0, 0, 0},
45742 { "SETNPCDATATILEHEIGHT", 2, 0, 0, 0},
45743 { "SETNPCDATAWPNSPRITE", 2, 0, 0, 0},
45744 { "SETNPCDATAHITSFX", 2, 0, 0, 0},
45745 { "GETNPCDATAHITSFX", 2, 0, 0, 0},
45746 //Combodata, one input no return
45747 { "GCDBLOCKENEM", 2, 0, 0, 0},
45748 { "GCDBLOCKHOLE", 2, 0, 0, 0},
45749 { "GCDBLOCKTRIG", 2, 0, 0, 0},
45750 { "GCDCONVEYSPDX", 2, 0, 0, 0},
45751 { "GCDCONVEYSPDY", 2, 0, 0, 0},
45752 { "GCDCREATEENEM", 2, 0, 0, 0},
45753 { "GCDCREATEENEMWH", 2, 0, 0, 0},
45754 { "GCDCREATEENEMCH", 2, 0, 0, 0},
45755 { "GCDDIRCHTYPE", 2, 0, 0, 0},
45756 { "GCDDISTCHTILES", 2, 0, 0, 0},
45757 { "GCDDIVEITEM", 2, 0, 0, 0},
45758 { "GCDDOCK", 2, 0, 0, 0},
45759 { "GCDFAIRY", 2, 0, 0, 0},
45760 { "GCDFFCOMBOATTRIB", 2, 0, 0, 0},
45761 { "GCDFOOTDECOTILE", 2, 0, 0, 0},
45762 { "GCDFOOTDECOTYPE", 2, 0, 0, 0},
45763 { "GCDHOOKSHOTGRAB", 2, 0, 0, 0},
45764 { "GCDLADDERPASS", 2, 0, 0, 0},
45765 { "GCDLOCKBLOCKTYPE", 2, 0, 0, 0},
45766 { "GCDLOCKBLOCKCHANGE", 2, 0, 0, 0},
45767 { "GCDMAGICMIRRORTYPE", 2, 0, 0, 0},
45768 { "GCDMODIFYHPAMOUNT", 2, 0, 0, 0},
45769 { "GCDMODIFYHPDELAY", 2, 0, 0, 0},
45770 { "GCDMODIFYHPTYPE", 2, 0, 0, 0},
45771 { "GCDMODIFYMPAMOUNT", 2, 0, 0, 0},
45772 { "GCDMODIFYMPDELAY", 2, 0, 0, 0},
45773 { "GCDMODIFYMPTYPE", 2, 0, 0, 0},
45774 { "GCDNOPUSHBLOCKS", 2, 0, 0, 0},
45775 { "GCDOVERHEAD", 2, 0, 0, 0},
45776 { "GCDPLACEENEMY", 2, 0, 0, 0},
45777 { "GCDPUSHDIR", 2, 0, 0, 0},
45778 { "GCDPUSHWEIGHT", 2, 0, 0, 0},
45779 { "GCDPUSHWAIT", 2, 0, 0, 0},
45780 { "GCDPUSHED", 2, 0, 0, 0},
45781 { "GCDRAFT", 2, 0, 0, 0},
45782 { "GCDRESETROOM", 2, 0, 0, 0},
45783 { "GCDSAVEPOINT", 2, 0, 0, 0},
45784 { "GCDSCREENFREEZE", 2, 0, 0, 0},
45785 { "GCDSECRETCOMBO", 2, 0, 0, 0},
45786 { "GCDSINGULAR", 2, 0, 0, 0},
45787 { "GCDSLOWMOVE", 2, 0, 0, 0},
45788 { "GCDSTATUE", 2, 0, 0, 0},
45789 { "GCDSTEPTYPE", 2, 0, 0, 0},
45790 { "GCDSTEPCHANGETO", 2, 0, 0, 0},
45791 { "GCDSTRIKEREMNANTS", 2, 0, 0, 0},
45792 { "GCDSTRIKEREMNANTSTYPE", 2, 0, 0, 0},
45793 { "GCDSTRIKECHANGE", 2, 0, 0, 0},
45794 { "GCDSTRIKECHANGEITEM", 2, 0, 0, 0},
45795 { "GCDTOUCHITEM", 2, 0, 0, 0},
45796 { "GCDTOUCHSTAIRS", 2, 0, 0, 0},
45797 { "GCDTRIGGERTYPE", 2, 0, 0, 0},
45798 { "GCDTRIGGERSENS", 2, 0, 0, 0},
45799 { "GCDWARPTYPE", 2, 0, 0, 0},
45800 { "GCDWARPSENS", 2, 0, 0, 0},
45801 { "GCDWARPDIRECT", 2, 0, 0, 0},
45802 { "GCDWARPLOCATION", 2, 0, 0, 0},
45803 { "GCDWATER", 2, 0, 0, 0},
45804 { "GCDWHISTLE", 2, 0, 0, 0},
45805 { "GCDWINGAME", 2, 0, 0, 0},
45806 { "GCDBLOCKWEAPLVL", 2, 0, 0, 0},
45807 { "GCDTILE", 2, 0, 0, 0},
45808 { "GCDFLIP", 2, 0, 0, 0},
45809 { "GCDWALK", 2, 0, 0, 0},
45810 { "GCDTYPE", 2, 0, 0, 0},
45811 { "GCDCSETS", 2, 0, 0, 0},
45812 { "GCDFOO", 2, 0, 0, 0},
45813 { "GCDFRAMES", 2, 0, 0, 0},
45814 { "GCDSPEED", 2, 0, 0, 0},
45815 { "GCDNEXTCOMBO", 2, 0, 0, 0},
45816 { "GCDNEXTCSET", 2, 0, 0, 0},
45817 { "GCDFLAG", 2, 0, 0, 0},
45818 { "GCDSKIPANIM", 2, 0, 0, 0},
45819 { "GCDNEXTTIMER", 2, 0, 0, 0},
45820 { "GCDSKIPANIMY", 2, 0, 0, 0},
45821 { "GCDANIMFLAGS", 2, 0, 0, 0},
45822 //combodata two input, one return
45823 { "GCDBLOCKWEAPON", 1, 0, 0, 0},
45824 { "GCDEXPANSION", 1, 0, 0, 0},
45825 { "GCDSTRIKEWEAPONS", 1, 0, 0, 0},
45826 //combodata two input, one return
45827 { "SCDBLOCKENEM", 2, 0, 0, 0},
45828 { "SCDBLOCKHOLE", 2, 0, 0, 0},
45829 { "SCDBLOCKTRIG", 2, 0, 0, 0},
45830 { "SCDCONVEYSPDX", 2, 0, 0, 0},
45831 { "SCDCONVEYSPDY", 2, 0, 0, 0},
45832 { "SCDCREATEENEM", 2, 0, 0, 0},
45833 { "SCDCREATEENEMWH", 2, 0, 0, 0},
45834 { "SCDCREATEENEMCH", 2, 0, 0, 0},
45835 { "SCDDIRCHTYPE", 2, 0, 0, 0},
45836 { "SCDDISTCHTILES", 2, 0, 0, 0},
45837 { "SCDDIVEITEM", 2, 0, 0, 0},
45838 { "SCDDOCK", 2, 0, 0, 0},
45839 { "SCDFAIRY", 2, 0, 0, 0},
45840 { "SCDFFCOMBOATTRIB", 2, 0, 0, 0},
45841 { "SCDFOOTDECOTILE", 2, 0, 0, 0},
45842 { "SCDFOOTDECOTYPE", 2, 0, 0, 0},
45843 { "SCDHOOKSHOTGRAB", 2, 0, 0, 0},
45844 { "SCDLADDERPASS", 2, 0, 0, 0},
45845 { "SCDLOCKBLOCKTYPE", 2, 0, 0, 0},
45846 { "SCDLOCKBLOCKCHANGE", 2, 0, 0, 0},
45847 { "SCDMAGICMIRRORTYPE", 2, 0, 0, 0},
45848 { "SCDMODIFYHPAMOUNT", 2, 0, 0, 0},
45849 { "SCDMODIFYHPDELAY", 2, 0, 0, 0},
45850 { "SCDMODIFYHPTYPE", 2, 0, 0, 0},
45851 { "SCDMODIFYMPAMOUNT", 2, 0, 0, 0},
45852 { "SCDMODIFYMPDELAY", 2, 0, 0, 0},
45853 { "SCDMODIFYMPTYPE", 2, 0, 0, 0},
45854 { "SCDNOPUSHBLOCKS", 2, 0, 0, 0},
45855 { "SCDOVERHEAD", 2, 0, 0, 0},
45856 { "SCDPLACEENEMY", 2, 0, 0, 0},
45857 { "SCDPUSHDIR", 2, 0, 0, 0},
45858 { "SCDPUSHWEIGHT", 2, 0, 0, 0},
45859 { "SCDPUSHWAIT", 2, 0, 0, 0},
45860 { "SCDPUSHED", 2, 0, 0, 0},
45861 { "SCDRAFT", 2, 0, 0, 0},
45862 { "SCDRESETROOM", 2, 0, 0, 0},
45863 { "SCDSAVEPOINT", 2, 0, 0, 0},
45864 { "SCDSCREENFREEZE", 2, 0, 0, 0},
45865 { "SCDSECRETCOMBO", 2, 0, 0, 0},
45866 { "SCDSINGULAR", 2, 0, 0, 0},
45867 { "SCDSLOWMOVE", 2, 0, 0, 0},
45868 { "SCDSTATUE", 2, 0, 0, 0},
45869 { "SCDSTEPTYPE", 2, 0, 0, 0},
45870 { "SCDSTEPCHANGETO", 2, 0, 0, 0},
45871 { "SCDSTRIKEREMNANTS", 2, 0, 0, 0},
45872 { "SCDSTRIKEREMNANTSTYPE", 2, 0, 0, 0},
45873 { "SCDSTRIKECHANGE", 2, 0, 0, 0},
45874 { "SCDSTRIKECHANGEITEM", 2, 0, 0, 0},
45875 { "SCDTOUCHITEM", 2, 0, 0, 0},
45876 { "SCDTOUCHSTAIRS", 2, 0, 0, 0},
45877 { "SCDTRIGGERTYPE", 2, 0, 0, 0},
45878 { "SCDTRIGGERSENS", 2, 0, 0, 0},
45879 { "SCDWARPTYPE", 2, 0, 0, 0},
45880 { "SCDWARPSENS", 2, 0, 0, 0},
45881 { "SCDWARPDIRECT", 2, 0, 0, 0},
45882 { "SCDWARPLOCATION", 2, 0, 0, 0},
45883 { "SCDWATER", 2, 0, 0, 0},
45884 { "SCDWHISTLE", 2, 0, 0, 0},
45885 { "SCDWINGAME", 2, 0, 0, 0},
45886 { "SCDBLOCKWEAPLVL", 2, 0, 0, 0},
45887 { "SCDTILE", 2, 0, 0, 0},
45888 { "SCDFLIP", 2, 0, 0, 0},
45889 { "SCDWALK", 2, 0, 0, 0},
45890 { "SCDTYPE", 2, 0, 0, 0},
45891 { "SCDCSETS", 2, 0, 0, 0},
45892 { "SCDFOO", 2, 0, 0, 0},
45893 { "SCDFRAMES", 2, 0, 0, 0},
45894 { "SCDSPEED", 2, 0, 0, 0},
45895 { "SCDNEXTCOMBO", 2, 0, 0, 0},
45896 { "SCDNEXTCSET", 2, 0, 0, 0},
45897 { "SCDFLAG", 2, 0, 0, 0},
45898 { "SCDSKIPANIM", 2, 0, 0, 0},
45899 { "SCDNEXTTIMER", 2, 0, 0, 0},
45900 { "SCDSKIPANIMY", 2, 0, 0, 0},
45901 { "SCDANIMFLAGS", 2, 0, 0, 0},
45902 { "GETNPCDATATILE", 2, 0, 0, 0},
45903 { "GETNPCDATAEHEIGHT", 2, 0, 0, 0},
45904 { "SETNPCDATATILE", 2, 0, 0, 0},
45905 { "SETNPCDATAEHEIGHT", 2, 0, 0, 0},
45906 { "GETSPRITEDATASTRING", 2, 0, 0, 0},
45907 //SpriteData
45908 { "GETSPRITEDATATILE", 2, 0, 0, 0},
45909 { "GETSPRITEDATAMISC", 2, 0, 0, 0},
45910 { "GETSPRITEDATACGETS", 2, 0, 0, 0},
45911 { "GETSPRITEDATAFRAMES", 2, 0, 0, 0},
45912 { "GETSPRITEDATASPEED", 2, 0, 0, 0},
45913 { "GETSPRITEDATATYPE", 2, 0, 0, 0},
45914 { "SETSPRITEDATASTRING", 2, 0, 0, 0},
45915 { "SETSPRITEDATATILE", 2, 0, 0, 0},
45916 { "SETSPRITEDATAMISC", 2, 0, 0, 0},
45917 { "SETSPRITEDATACSETS", 2, 0, 0, 0},
45918 { "SETSPRITEDATAFRAMES", 2, 0, 0, 0},
45919 { "SETSPRITEDATASPEED", 2, 0, 0, 0},
45920 { "SETSPRITEDATATYPE", 2, 0, 0, 0},
45921 //Game->SetContinueScreenSetting
45922 { "SETCONTINUESCREEN", 2, 0, 0, 0},
45923 //Game->SetContinueScreenString
45924 { "SETCONTINUESTRING", 2, 0, 0, 0},
45925
45926 { "LOADNPCDATAR", 1, 0, 0, 0},
45927 { "LOADNPCDATAV", 1, 1, 0, 0},
45928
45929 { "LOADCOMBODATAR", 1, 0, 0, 0},
45930 { "LOADCOMBODATAV", 1, 1, 0, 0},
45931
45932 { "LOADMAPDATAR", 1, 0, 0, 0},
45933 { "LOADMAPDATAV", 1, 1, 0, 0},
45934
45935 { "LOADSPRITEDATAR", 1, 0, 0, 0},
45936 { "LOADSPRITEDATAV", 1, 1, 0, 0},
45937
45938 { "LOADSCREENDATAR", 1, 0, 0, 0},
45939 { "LOADSCREENDATAV", 1, 1, 0, 0},
45940
45941 { "LOADBITMAPDATAR", 1, 0, 0, 0},
45942 { "LOADBITMAPDATAV", 1, 1, 0, 0},
45943
45944 { "LOADSHOPR", 1, 0, 0, 0},
45945 { "LOADSHOPV", 1, 1, 0, 0},
45946
45947 { "LOADINFOSHOPR", 1, 0, 0, 0},
45948 { "LOADINFOSHOPV", 1, 1, 0, 0},
45949
45950 { "LOADMESSAGEDATAR", 1, 0, 0, 0},
45951 { "LOADMESSAGEDATAV", 1, 1, 0, 0},
45952 { "MESSAGEDATASETSTRINGR", 1, 0, 0, 0},
45953 { "MESSAGEDATASETSTRINGV", 1, 1, 0, 0},
45954 { "MESSAGEDATAGETSTRINGR", 1, 0, 0, 0},
45955 { "MESSAGEDATAGETSTRINGV", 1, 1, 0, 0},
45956
45957 { "LOADDMAPDATAR", 1, 0, 0, 0},
45958 { "LOADDMAPDATAV", 1, 1, 0, 0},
45959 { "DMAPDATAGETNAMER", 1, 0, 0, 0},
45960 { "DMAPDATAGETNAMEV", 1, 1, 0, 0},
45961 { "DMAPDATASETNAMER", 1, 0, 0, 0},
45962 { "DMAPDATASETNAMEV", 1, 1, 0, 0},
45963 { "DMAPDATAGETTITLER", 1, 0, 0, 0},
45964 { "DMAPDATAGETTITLEV", 1, 1, 0, 0},
45965 { "DMAPDATASETTITLER", 1, 0, 0, 0},
45966 { "DMAPDATASETTITLEV", 1, 1, 0, 0},
45967
45968 { "DMAPDATAGETINTROR", 1, 0, 0, 0},
45969 { "DMAPDATAGETINTROV", 1, 1, 0, 0},
45970 { "DMAPDATANSETITROR", 1, 0, 0, 0},
45971 { "DMAPDATASETINTROV", 1, 1, 0, 0},
45972 { "DMAPDATAGETMUSICR", 1, 0, 0, 0},
45973 { "DMAPDATAGETMUSICV", 1, 1, 0, 0},
45974 { "DMAPDATASETMUSICR", 1, 0, 0, 0},
45975 { "DMAPDATASETMUSICV", 1, 1, 0, 0},
45976
45977 { "ADJUSTSFXVOLUMER", 1, 0, 0, 0},
45978 { "ADJUSTSFXVOLUMEV", 1, 1, 0, 0},
45979
45980 { "ADJUSTVOLUMER", 1, 0, 0, 0},
45981 { "ADJUSTVOLUMEV", 1, 1, 0, 0},
45982
45983 { "FXWAVYR", 1, 0, 0, 0},
45984 { "FXWAVYV", 1, 1, 0, 0},
45985
45986 { "FXZAPR", 1, 0, 0, 0},
45987 { "FXZAPV", 1, 1, 0, 0},
45988
45989 { "GREYSCALER", 1, 0, 0, 0},
45990 { "GREYSCALEV", 1, 1, 0, 0},
45991 { "RETURN", 0, 0, 0, 0},
45992 { "MONOCHROMER", 1, 0, 0, 0},
45993 { "MONOCHROMEV", 1, 1, 0, 0},
45994 { "CLEARTINT", 0, 0, 0, 0},
45995 { "TINT", 0, 0, 0, 0},
45996 { "MONOHUE", 0, 0, 0, 0},
45997
45998 { "BMPRECTR", 0, 0, 0, 0},
45999 { "BMPCIRCLER", 0, 0, 0, 0},
46000 { "BMPARCR", 0, 0, 0, 0},
46001 { "BMPELLIPSER", 0, 0, 0, 0},
46002 { "BMPLINER", 0, 0, 0, 0},
46003 { "BMPSPLINER", 0, 0, 0, 0},
46004 { "BMPPUTPIXELR", 0, 0, 0, 0},
46005 { "BMPDRAWTILER", 0, 0, 0, 0},
46006 { "BMPDRAWCOMBOR", 0, 0, 0, 0},
46007 { "BMPFASTTILER", 0, 0, 0, 0},
46008 { "BMPFASTCOMBOR", 0, 0, 0, 0},
46009 { "BMPDRAWCHARR", 0, 0, 0, 0},
46010 { "BMPDRAWINTR", 0, 0, 0, 0},
46011 { "BMPDRAWSTRINGR", 0, 0, 0, 0},
46012 { "BMPQUADR", 0, 0, 0, 0},
46013 { "BMPQUAD3DR", 0, 0, 0, 0},
46014 { "BMPTRIANGLER", 0, 0, 0, 0},
46015 { "BMPTRIANGLE3DR", 0, 0, 0, 0},
46016 { "BMPPOLYGONR", 0, 0, 0, 0},
46017 { "BMPDRAWLAYERR", 0, 0, 0, 0},
46018 { "BMPDRAWSCREENR", 0, 0, 0, 0},
46019 { "BMPBLIT", 0, 0, 0, 0},
46020
46021 { "LINKWARPEXR", 1, 0, 0, 0},
46022 { "LINKWARPEXV", 1, 1, 0, 0},
46023 { "LINKEXPLODER", 1, 0, 0, 0},
46024 { "LINKEXPLODEV", 1, 1, 0, 0},
46025 { "NPCEXPLODER", 1, 0, 0, 0},
46026 { "NPCEXPLODEV", 1, 1, 0, 0},
46027
46028 { "ITEMEXPLODER", 1, 0, 0, 0},
46029 { "ITEMEXPLODEV", 1, 1, 0, 0},
46030 { "LWEAPONEXPLODER", 1, 0, 0, 0},
46031 { "LWEAPONEXPLODEV", 1, 1, 0, 0},
46032 { "EWEAPONEXPLODER", 1, 0, 0, 0},
46033 { "EWEAPONEXPLODEV", 1, 1, 0, 0},
46034 { "RUNITEMSCRIPT", 0, 0, 0, 0},
46035 { "GETRTCTIMER", 1, 0, 0, 0},
46036 { "GETRTCTIMEV", 1, 1, 0, 0},
46037
46038 //new npc functions for npc scripts
46039 { "NPCDEAD", 1, 0, 0, 0},
46040 { "NPCKICKBUCKET", 0, 0, 0, 0},
46041 { "NPCSTOPBGSFX", 0, 0, 0, 0},
46042 { "NPCCANMOVE", 1, 0, 0, 0},
46043 { "NPCNEWDIR8", 0, 0, 0, 0},
46044 { "NPCNEWDIR", 0, 0, 0, 0},
46045 { "NPCCONSTWALK", 0, 0, 0, 0},
46046 { "NPCCONSTWALK8", 0, 0, 0, 0},
46047 { "NPCVARWALK", 0, 0, 0, 0},
46048 { "NPCVARWALK8", 0, 0, 0, 0},
46049 { "NPCHALTWALK", 0, 0, 0, 0},
46050 { "NPCHALTWALK8", 0, 0, 0, 0},
46051 { "NPCFLOATWALK", 0, 0, 0, 0},
46052 // moved to a var: { "NPCLINEDUP", 0, 0, 0, 0},
46053 { "NPCLINKINRANGE", 1, 0, 0, 0},
46054 { "NPCATTACK", 0, 0, 0, 0},
46055 { "NPCPLACEONAXIS", 0, 0, 0, 0},
46056 { "NPCADD", 1, 0, 0, 0},
46057 { "NPCFIREBREATH", 0, 0, 0, 0},
46058 { "NPCCANSLIDE", 1, 0, 0, 0},
46059 { "NPCSLIDE", 1, 0, 0, 0},
46060 { "NPCHITWITH", 1, 0, 0, 0},
46061 { "NPCGETINITDLABEL", 0, 0, 0, 0},
46062 // moved to a var: { "NPCCOLLISION", 0, 0, 0, 0}, //how to implement this?
46063 { "GAMECONTINUE", 0, 0, 0, 0},
46064 { "MAPDATAISSOLID", 1, 0, 0, 0},
46065 { "SHOWF6SCREEN", 0, 0, 0, 0},
46066 { "NPCDATAGETNAME", 1, 0, 0, 0},
46067 { "PLAYENHMUSICEX", 2, 0, 0, 0},
46068 { "GETENHMUSICPOS", 1, 0, 0, 0},
46069 { "SETENHMUSICPOS", 1, 0, 0, 0},
46070 { "SETENHMUSICSPEED", 1, 0, 0, 0},
46071 { "ISVALIDBITMAP", 1, 0, 0, 0},
46072 { "READBITMAP", 0, 0, 0, 0},
46073 { "WRITEBITMAP", 0, 0, 0, 0},
46074 { "ALLOCATEBITMAP", 1, 0, 0, 0},
46075 { "CLEARBITMAP", 0, 0, 0, 0},
46076 { "REGENERATEBITMAP", 0, 0, 0, 0},
46077 { "BMPBLITTO", 0, 0, 0, 0},
46078
46079 { "BMPDRAWSCREENSOLIDR", 0, 0, 0, 0},
46080 { "BMPDRAWSCREENCOMBOFR", 0, 0, 0, 0},
46081 { "BMPDRAWSCREENCOMBOIR", 0, 0, 0, 0},
46082 { "BMPDRAWSCREENCOMBOTR", 0, 0, 0, 0},
46083 { "BMPDRAWSCREENSOLID2R", 0, 0, 0, 0},
46084 { "GRAPHICSGETPIXEL", 1, 0, 0, 0},
46085
46086 { "BMPDRAWLAYERSOLIDR", 0, 0, 0, 0},
46087 { "BMPDRAWLAYERCFLAGR", 0, 0, 0, 0},
46088 { "BMPDRAWLAYERCTYPER", 0, 0, 0, 0},
46089 { "BMPDRAWLAYERCIFLAGR", 0, 0, 0, 0},
46090 { "BMPDRAWLAYERSOLIDITYR", 0, 0, 0, 0},
46091 { "BMPMODE7", 0, 0, 0, 0},
46092 { "BITMAPGETPIXEL", 0, 0, 0, 0},
46093 { "NOP", 0, 0, 0, 0},
46094 { "STRINGCOMPARE", 1, 0, 0, 0},
46095 { "STRINGNCOMPARE", 1, 0, 0, 0},
46096 { "STRINGLENGTH", 2, 0, 0, 0},
46097 { "STRINGCOPY", 2, 0, 0, 0},
46098 { "CASTBOOLI", 1, 0, 0, 0},
46099 { "CASTBOOLF", 1, 0, 0, 0},
46100 { "SETTRUEI", 1, 0, 0, 0},
46101 { "SETFALSEI", 1, 0, 0, 0},
46102 { "SETMOREI", 1, 0, 0, 0},
46103 { "SETLESSI", 1, 0, 0, 0},
46104
46105 { "ARRAYCOPY", 2, 0, 0, 0},
46106 { "ARRAYNCOPY", 1, 0, 0, 0},
46107
46108 //1 INPUT, NO RETURN
46109 { "REMCHR", 2, 0, 0, 0},
46110 { "STRINGUPPERLOWER", 2, 0, 0, 0},
46111 { "STRINGLOWERUPPER", 2, 0, 0, 0},
46112 { "STRINGCONVERTCASE", 2, 0, 0, 0},
46113
46114 //1 input, 1 ret
46115 { "XLEN", 2, 0, 0, 0},
46116 { "XTOI", 2, 0, 0, 0},
46117 { "ILEN", 2, 0, 0, 0},
46118 { "ATOI", 2, 0, 0, 0},
46119
46120 //2 INPUT, 1 RET, based on strcmp
46121 { "STRCSPN", 1, 0, 0, 0},
46122 { "STRSTR", 1, 0, 0, 0},
46123 { "XTOA", 2, 0, 0, 0},
46124 { "ITOA", 2, 0, 0, 0},
46125 { "STRCAT", 1, 0, 0, 0},
46126 { "STRSPN", 1, 0, 0, 0},
46127 { "STRCHR", 1, 0, 0, 0},
46128 { "STRRCHR", 1, 0, 0, 0},
46129 //2 INP, 1 RET OVERLOADS
46130 { "XLEN2", 1, 0, 0, 0},
46131 { "XTOI2", 1, 0, 0, 0},
46132 { "ILEN2", 1, 0, 0, 0},
46133 { "ATOI2", 1, 0, 0, 0},
46134 { "REMCHR2", 1, 0, 0, 0},
46135
46136 //3 INPUT 1 RET
46137 { "XTOA3", 1, 0, 0, 0},
46138 { "STRCATF", 1, 0, 0, 0},
46139 { "ITOA3", 1, 0, 0, 0},
46140 { "STRSTR3", 1, 0, 0, 0},
46141 { "REMNCHR3", 1, 0, 0, 0},
46142 { "STRCAT3", 1, 0, 0, 0},
46143 { "STRNCAT3", 1, 0, 0, 0},
46144 { "STRCHR3", 1, 0, 0, 0},
46145 { "STRRCHR3", 1, 0, 0, 0},
46146 { "STRSPN3", 1, 0, 0, 0},
46147 { "STRCSPN3", 1, 0, 0, 0},
46148
46149
46150 { "UPPERTOLOWER", 2, 0, 0, 0},
46151 { "LOWERTOUPPER", 2, 0, 0, 0},
46152 { "CONVERTCASE", 2, 0, 0, 0},
46153 //Game->Get
46154 { "GETNPCSCRIPT", 1, 0, 0, 0},
46155 { "GETLWEAPONSCRIPT", 1, 0, 0, 0},
46156 { "GETEWEAPONSCRIPT", 1, 0, 0, 0},
46157 { "GETHEROSCRIPT", 1, 0, 0, 0},
46158 { "GETGLOBALSCRIPT", 1, 0, 0, 0},
46159 { "GETDMAPSCRIPT", 1, 0, 0, 0},
46160 { "GETSCREENSCRIPT", 1, 0, 0, 0},
46161 { "GETSPRITESCRIPT", 1, 0, 0, 0},
46162 { "GETUNTYPEDSCRIPT", 1, 0, 0, 0},
46163 { "GETSUBSCREENSCRIPT", 1, 0, 0, 0},
46164 { "GETNPCBYNAME", 1, 0, 0, 0},
46165 { "GETITEMBYNAME", 1, 0, 0, 0},
46166 { "GETCOMBOBYNAME", 1, 0, 0, 0},
46167 { "GETDMAPBYNAME", 1, 0, 0, 0},
46168
46169 { "SRNDR", 1, 0, 0, 0},
46170 { "SRNDV", 1, 1, 0, 0},
46171 { "SRNDRND", 1, 0, 0, 0},
46172 { "SAVEGAMESTRUCTS", 2, 0, 0, 0},
46173 { "READGAMESTRUCTS", 2, 0, 0, 0},
46174 { "ANDR32", 2, 0, 0, 0},
46175 { "ANDV32", 2, 0, 1, 0},
46176 { "ORR32", 2, 0, 0, 0},
46177 { "ORV32", 2, 0, 1, 0},
46178 { "XORR32", 2, 0, 0, 0},
46179 { "XORV32", 2, 0, 1, 0},
46180 { "BITNOT32", 1, 0, 0, 0},
46181 { "LSHIFTR32", 2, 0, 0, 0},
46182 { "LSHIFTV32", 2, 0, 1, 0},
46183 { "RSHIFTR32", 2, 0, 0, 0},
46184 { "RSHIFTV32", 2, 0, 1, 0},
46185 { "ISALLOCATEDBITMAP", 1, 0, 0, 0},
46186 { "FONTHEIGHTR", 1, 0, 0, 0},
46187 { "STRINGWIDTHR", 2, 0, 0, 0},
46188 { "CHARWIDTHR", 2, 0, 0, 0},
46189 { "MESSAGEWIDTHR", 1, 0, 0, 0},
46190 { "MESSAGEHEIGHTR", 1, 0, 0, 0},
46191 { "ISVALIDARRAY", 1, 0, 0, 0},
46192 { "DIREXISTS", 1, 0, 0, 0},
46193 { "GAMESAVEQUIT", 0, 0, 0, 0},
46194 { "GAMESAVECONTINUE", 0, 0, 0, 0},
46195 { "DRAWTILECLOAKEDR", 0, 0, 0, 0},
46196 { "BMPDRAWTILECLOAKEDR", 0, 0, 0, 0},
46197 { "DRAWCOMBOCLOAKEDR", 0, 0, 0, 0},
46198 { "BMPDRAWCOMBOCLOAKEDR", 0, 0, 0, 0},
46199 { "NPCKNOCKBACK", 2, 0, 0, 0},
46200 { "CLOSEWIPE", 0, 0, 0, 0},
46201 { "OPENWIPESHAPE", 1, 0, 0, 0},
46202 { "CLOSEWIPESHAPE", 1, 0, 0, 0},
46203 { "FILEEXISTS", 1, 0, 0, 0},
46204 { "BITMAPCLEARTOCOLOR", 0, 0, 0, 0},
46205 { "LOADNPCBYSUID", 1, 0, 0, 0},
46206 { "LOADLWEAPONBYSUID", 1, 0, 0, 0},
46207 { "LOADWEAPONCBYSUID", 1, 0, 0, 0},
46208 { "LOADDROPSETR", 1, 0, 0, 0},
46209 { "LOADTMPSCR", 1, 0, 0, 0},
46210 { "LOADSCROLLSCR", 1, 0, 0, 0},
46211 { "MAPDATAISSOLIDLYR", 1, 0, 0, 0},
46212 { "ISSOLIDLAYER", 1, 0, 0, 0},
46213 { "BREAKPOINT", 1, 0, 0, 0},
46214 { "TOBYTE", 1, 0, 0, 0},
46215 { "TOWORD", 1, 0, 0, 0},
46216 { "TOSHORT", 1, 0, 0, 0},
46217 { "TOSIGNEDBYTE", 1, 0, 0, 0},
46218 { "TOINTEGER", 1, 0, 0, 0},
46219 { "FLOOR", 1, 0, 0, 0},
46220 { "CEILING", 1, 0, 0, 0},
46221
46222 { "FILECLOSE", 0, 0, 0, 0},
46223 { "FILEFREE", 0, 0, 0, 0},
46224 { "FILEISALLOCATED", 0, 0, 0, 0},
46225 { "FILEISVALID", 0, 0, 0, 0},
46226 { "FILEALLOCATE", 0, 0, 0, 0},
46227 { "FILEFLUSH", 0, 0, 0, 0},
46228 { "FILEGETCHAR", 0, 0, 0, 0},
46229 { "FILEREWIND", 0, 0, 0, 0},
46230 { "FILECLEARERR", 0, 0, 0, 0},
46231
46232 { "FILEOPEN", 1, 0, 0, 0},
46233 { "FILECREATE", 1, 0, 0, 0},
46234 { "FILEREADSTR", 1, 0, 0, 0},
46235 { "FILEWRITESTR", 1, 0, 0, 0},
46236 { "FILEPUTCHAR", 1, 0, 0, 0},
46237 { "FILEUNGETCHAR", 1, 0, 0, 0},
46238
46239 { "FILEREADCHARS", 2, 0, 0, 0},
46240 { "FILEREADINTS", 2, 0, 0, 0},
46241 { "FILEWRITECHARS", 2, 0, 0, 0},
46242 { "FILEWRITEINTS", 2, 0, 0, 0},
46243 { "FILESEEK", 2, 0, 0, 0},
46244 { "FILEOPENMODE", 2, 0, 0, 0},
46245 { "FILEGETERROR", 1, 0, 0, 0},
46246
46247 { "BITMAPFREE", 0, 0, 0, 0},
46248
46249 { "POPARGS", 2, 0, 1, 0},
46250 { "GAMERELOAD", 0, 0, 0, 0},
46251
46252 { "READPODARRAYR", 2, 0, 0, 0},
46253 { "READPODARRAYV", 2, 0, 1, 0},
46254 { "WRITEPODARRAYRR", 2, 0, 0, 0},
46255 { "WRITEPODARRAYRV", 2, 0, 1, 0},
46256 { "WRITEPODARRAYVR", 2, 1, 0, 0},
46257 { "WRITEPODARRAYVV", 2, 1, 1, 0},
46258
46259 { "PRINTFV", 1, 1, 0, 0},
46260 { "SPRINTFV", 1, 1, 0, 0},
46261
46262 { "STRCMPR", 2, 0, 0, 0},
46263 { "STRICMPR", 2, 0, 0, 0},
46264 { "STRINGICOMPARE", 1, 0, 0, 0},
46265 { "STRINGNICOMPARE", 1, 0, 0, 0},
46266
46267 { "FILEREMOVE", 0, 0, 0, 0},
46268 { "FILESYSREMOVE", 1, 0, 0, 0},
46269
46270 { "DRAWSTRINGR2", 0, 0, 0, 0},
46271 { "BMPDRAWSTRINGR2", 0, 0, 0, 0},
46272
46273 { "MODULEGETIC", 2, 0, 0, 0},
46274 { "ITOACAT", 2, 0, 0, 0},
46275
46276 { "FRAMER", 0, 0, 0, 0},
46277 { "BMPFRAMER", 0, 0, 0, 0},
46278
46279 { "LOADDIRECTORYR", 1, 0, 0, 0},
46280 { "DIRECTORYGET", 2, 0, 0, 0},
46281 { "DIRECTORYRELOAD", 0, 0, 0, 0},
46282 { "DIRECTORYFREE", 0, 0, 0, 0},
46283 { "FILEWRITEBYTES", 2, 0, 0, 0},
46284 { "GETCOMBOSCRIPT", 1, 0, 0, 0},
46285 { "FILEREADBYTES", 2, 0, 0, 0},
46286
46287 { "LOADRNG", 0, 0, 0, 0},
46288 { "RNGRAND1", 0, 0, 0, 0},
46289 { "RNGRAND2", 1, 0, 0, 0},
46290 { "RNGRAND3", 2, 0, 0, 0},
46291 { "RNGLRAND1", 0, 0, 0, 0},
46292 { "RNGLRAND2", 1, 0, 0, 0},
46293 { "RNGLRAND3", 2, 0, 0, 0},
46294 { "RNGSEED", 1, 0, 0, 0},
46295 { "RNGRSEED", 0, 0, 0, 0},
46296 { "RNGFREE", 0, 0, 0, 0},
46297 { "LWPNDEL", 0, 0, 0, 0},
46298 { "EWPNDEL", 0, 0, 0, 0},
46299 { "ITEMDEL", 0, 0, 0, 0},
46300 { "BMPWRITETILE", 0, 0, 0, 0},
46301 { "BMPDITHER", 0, 0, 0, 0},
46302 { "BMPREPLCOLOR", 0, 0, 0, 0},
46303 { "BMPSHIFTCOLOR", 0, 0, 0, 0},
46304 { "BMPMASKDRAW", 0, 0, 0, 0},
46305 { "RESIZEARRAYR", 2, 0, 0, 0},
46306 { "BSHOPNAMEGET", 1, 0, 0, 0},
46307 { "BSHOPNAMESET", 1, 0, 0, 0},
46308 { "BOTTLENAMEGET", 1, 0, 0, 0},
46309 { "BOTTLENAMESET", 1, 0, 0, 0},
46310 { "LOADBOTTLETYPE", 1, 0, 0, 0},
46311 { "LOADBSHOPDATA", 1, 0, 0, 0},
46312 { "SWITCHNPC", 1, 0, 0, 0},
46313 { "SWITCHCMB", 2, 0, 0, 0},
46314 { "SWITCHITM", 1, 0, 0, 0},
46315 { "SWITCHLW", 1, 0, 0, 0},
46316 { "SWITCHEW", 1, 0, 0, 0},
46317 { "SCREENDOSPAWN", 0, 0, 0, 0},
46318 { "NPCMOVEPAUSED", 0, 0, 0, 0},
46319 { "NPCMOVE", 0, 0, 0, 0},
46320 { "NPCMOVEANGLE", 0, 0, 0, 0},
46321 { "NPCMOVEXY", 0, 0, 0, 0},
46322 { "NPCCANMOVEDIR", 0, 0, 0, 0},
46323 { "NPCCANMOVEANGLE", 0, 0, 0, 0},
46324 { "NPCCANMOVEXY", 0, 0, 0, 0},
46325 { "SELECTXWPNR", 1, 0, 0, 0},
46326 { "SELECTYWPNR", 1, 0, 0, 0},
46327 { "BITMAPOWN", 0, 0, 0, 0},
46328 { "FILEOWN", 0, 0, 0, 0},
46329 { "DIRECTORYOWN", 0, 0, 0, 0},
46330 { "RNGOWN", 0, 0, 0, 0},
46331 { "LOADGENERICDATA", 1, 0, 0, 0},
46332 { "RUNGENFRZSCR", 1, 0, 0, 0},
46333 { "WAITTO", 2, 0, 0, 0},
46334 { "GETGENERICSCRIPT", 1, 0, 0, 0},
46335 { "KILLPLAYER", 1, 0, 0, 0},
46336 { "DEGTORAD", 2, 0, 0, 0},
46337 { "RADTODEG", 2, 0, 0, 0},
46338 { "LWPNMAKEANGULAR", 1, 0, 0, 0},
46339 { "EWPNMAKEANGULAR", 1, 0, 0, 0},
46340 { "LWPNMAKEDIRECTIONAL", 1, 0, 0, 0},
46341 { "EWPNMAKEDIRECTIONAL", 1, 0, 0, 0},
46342 { "BMPMASKDRAW2", 0, 0, 0, 0},
46343 { "BMPMASKDRAW3", 0, 0, 0, 0},
46344 { "BMPMASKBLIT", 0, 0, 0, 0},
46345 { "BMPMASKBLIT2", 0, 0, 0, 0},
46346 { "BMPMASKBLIT3", 0, 0, 0, 0},
46347 { "SUBV2", 2, 1, 0, 0},
46348 { "DIVV2", 2, 1, 0, 0},
46349 { "COMPAREV2", 2, 1, 0, 0},
46350 { "MODV2", 2, 1, 0, 0},
46351 { "STACKFREE", 0, 0, 0, 0},
46352 { "STACKOWN", 0, 0, 0, 0},
46353 { "STACKGET", 1, 0, 0, 0},
46354 { "STACKSET", 2, 0, 0, 0},
46355 { "STACKPOPBACK", 0, 0, 0, 0},
46356 { "STACKPOPFRONT", 0, 0, 0, 0},
46357 { "STACKPEEKBACK", 0, 0, 0, 0},
46358 { "STACKPEEKFRONT", 0, 0, 0, 0},
46359 { "STACKPUSHBACK", 1, 0, 0, 0},
46360 { "STACKPUSHFRONT", 1, 0, 0, 0},
46361 { "LOADSTACK", 0, 0, 0, 0},
46362 { "STACKCLEAR", 0, 0, 0, 0},
46363 { "POWERV2", 2, 1, 0, 0},
46364 { "LPOWERR", 2, 0, 0, 0},
46365 { "LPOWERV", 2, 0, 1, 0},
46366 { "LPOWERV2", 2, 1, 0, 0},
46367 { "SCRTRIGGERCOMBO", 2, 0, 0, 0},
46368 { "WAITEVENT", 0, 0, 0, 0},
46369 { "OWNARRAYR", 1, 0, 0, 0},
46370 { "DESTROYARRAYR", 1, 0, 0, 0},
46371 { "GRAPHICSCOUNTCOLOR", 1, 0, 0, 0},
46372 { "WRITEPODSTRING", 1, 0, 0, 1},
46373 { "WRITEPODARRAY", 1, 0, 0, 2},
46374 { "ZCLASS_CONSTRUCT", 1, 0, 0, 2},
46375 { "ZCLASS_READ", 2, 0, 1, 0},
46376 { "ZCLASS_WRITE", 2, 0, 1, 0},
46377 { "ZCLASS_FREE", 1, 0, 0, 0},
46378 { "ZCLASS_OWN", 1, 0, 0, 0},
46379 { "STARTDESTRUCTOR", 0, 0, 0, 1},
46380 { "ZCLASS_GLOBALIZE", 1, 0, 0, 0},
46381 { "LOADD", 2, 0, 1, 0},
46382 { "STORED", 2, 0, 1, 0},
46383 { "OBJ_OWN_BITMAP", 2, 0, 1, 0},
46384 { "OBJ_OWN_PALDATA", 2, 0, 1, 0},
46385 { "OBJ_OWN_FILE", 2, 0, 1, 0},
46386 { "OBJ_OWN_DIR", 2, 0, 1, 0},
46387 { "OBJ_OWN_STACK", 2, 0, 1, 0},
46388 { "OBJ_OWN_RNG", 2, 0, 1, 0},
46389 { "OBJ_OWN_CLASS", 2, 0, 1, 0},
46390 { "OBJ_OWN_ARRAY", 2, 0, 1, 0},
46391 { "QUIT_NO_DEALLOC", 0, 0, 0, 0},
46392 { "GAMESETCUSTOMCURSOR", 0, 0, 0, 0},
46393 { "NPCCANPLACE", 0, 0, 0, 0},
46394 { "ITEMGETDISPLAYNAME", 1, 0, 0, 0},
46395 { "ITEMSETDISPLAYNAME", 1, 0, 0, 0},
46396 { "ITEMGETSHOWNNAME", 1, 0, 0, 0},
46397 { "HEROMOVEXY", 0, 0, 0, 0},
46398 { "HEROCANMOVEXY", 0, 0, 0, 0},
46399 { "HEROLIFTRELEASE", 0, 0, 0, 0},
46400 { "HEROLIFTGRAB", 0, 0, 0, 0},
46401 { "LOADPORTAL", 0, 0, 0, 0},
46402 { "CREATEPORTAL", 0, 0, 0, 0},
46403 { "LOADSAVPORTAL", 0, 0, 0, 0},
46404 { "CREATESAVPORTAL", 0, 0, 0, 0},
46405 { "CREATEPALDATA", 0, 0, 0, 0 },
46406 { "CREATEPALDATACLR", 1, 0, 0, 0 },
46407 { "MIXCLR", 0, 0, 0, 0 },
46408 { "CREATERGBHEX", 1, 0, 0, 0 },
46409 { "CREATERGB", 0, 0, 0, 0 },
46410 { "PALDATALOADLEVEL", 1, 0, 0, 0 },
46411 { "PALDATALOADSPRITE", 1, 0, 0, 0 },
46412 { "PALDATALOADMAIN", 0, 0, 0, 0 },
46413 { "PALDATALOADCYCLE", 1, 0, 0, 0 },
46414 { "PALDATALOADBITMAP", 1, 0, 0, 0 },
46415 { "PALDATAWRITELEVEL", 1, 0, 0, 0 },
46416 { "PALDATAWRITELEVELCS", 2, 0, 0, 0 },
46417 { "PALDATAWRITESPRITE", 1, 0, 0, 0 },
46418 { "PALDATAWRITESPRITECS", 2, 0, 0, 0 },
46419 { "PALDATAWRITEMAIN", 0, 0, 0, 0 },
46420 { "PALDATAWRITEMAINCS", 1, 0, 0, 0 },
46421 { "PALDATAWRITECYCLE", 1, 0, 0, 0 },
46422 { "PALDATAWRITECYCLECS", 2, 0, 0, 0 },
46423 { "PALDATAVALIDCLR", 1, 0, 0, 0 },
46424 { "PALDATACLEARCLR", 1, 0, 0, 0 },
46425 { "PALDATACLEARCSET", 1, 0, 0, 0 },
46426 { "PALDATAMIX", 0, 0, 0, 0 },
46427 { "PALDATAMIXCS", 0, 0, 0, 0 },
46428 { "PALDATACOPY", 1, 0, 0, 0 },
46429 { "PALDATACOPYCSET", 0, 0, 0, 0 },
46430 { "PALDATAFREE", 0, 0, 0, 0 },
46431 { "PALDATAOWN", 0, 0, 0, 0 },
46432 { "MAXVARG", 0, 0, 0, 0 },
46433 { "MINVARG", 0, 0, 0, 0 },
46434 { "CHOOSEVARG", 0, 0, 0, 0 },
46435 { "PUSHVARGV", 1, 1, 0, 0 },
46436 { "PUSHVARGR", 1, 0, 0, 0 },
46437 { "PRINTFVARG", 0, 0, 0, 0 },
46438 { "SPRINTFVARG", 0, 0, 0, 0 },
46439 { "TRACELR", 1, 0, 0, 0 },
46440 { "WAITFRAMESR", 1, 0, 0, 0 },
46441 { "RESRVD_OP_Z3_01", 0, 0, 0, 0 },
46442 { "RESRVD_OP_Z3_02", 0, 0, 0, 0 },
46443 { "RESRVD_OP_Z3_03", 0, 0, 0, 0 },
46444 { "RESRVD_OP_Z3_04", 0, 0, 0, 0 },
46445 { "RESRVD_OP_Z3_05", 0, 0, 0, 0 },
46446 { "RESRVD_OP_Z3_06", 0, 0, 0, 0 },
46447 { "RESRVD_OP_Z3_07", 0, 0, 0, 0 },
46448 { "RESRVD_OP_Z3_08", 0, 0, 0, 0 },
46449 { "RESRVD_OP_Z3_09", 0, 0, 0, 0 },
46450 { "RESRVD_OP_Z3_10", 0, 0, 0, 0 },
46451 { "PORTALREMOVE", 0, 0, 0, 0 },
46452 { "SAVEDPORTALREMOVE", 0, 0, 0, 0 },
46453 { "SAVEDPORTALGENERATE", 0, 0, 0, 0 },
46454 { "PORTALUSESPRITE", 1, 0, 0, 0 },
46455 { "HEROMOVEATANGLE", 0, 0, 0, 0 },
46456 { "HEROCANMOVEATANGLE", 0, 0, 0, 0 },
46457 { "HEROMOVE", 0, 0, 0, 0 },
46458 { "HEROCANMOVE", 0, 0, 0, 0 },
46459 { "DRAWLIGHT_CIRCLE", 0, 0, 0, 0 },
46460 { "DRAWLIGHT_SQUARE", 0, 0, 0, 0 },
46461 { "DRAWLIGHT_CONE", 0, 0, 0, 0 },
46462 { "PEEK", 1, 0, 0, 0 },
46463 { "PEEKATV", 2, 0, 1, 0 },
46464 { "MAKEVARGARRAY", 0, 0, 0, 0 },
46465 { "PRINTFA", 0, 0, 0, 0 },
46466 { "SPRINTFA", 0, 0, 0, 0 },
46467 { "CURRENTITEMID", 0, 0, 0, 0 },
46468 { "ARRAYPUSH", 0, 0, 0, 0 },
46469 { "ARRAYPOP", 0, 0, 0, 0 },
46470 { "LOADSUBDATARV", 2, 0, 1, 0 },
46471 { "SWAPSUBSCREENV", 1, 1, 0, 0 },
46472 { "SUBDATA_GET_NAME", 1, 0, 0, 0 },
46473 { "SUBDATA_SET_NAME", 1, 0, 0, 0 },
46474 { "CONVERTFROMRGB", 0, 0, 0, 0 },
46475 { "CONVERTTORGB", 0, 0, 0, 0 },
46476 { "GETENHMUSICLEN", 1, 0, 0, 0 },
46477 { "SETENHMUSICLOOP", 2, 0, 0, 0 },
46478 { "PLAYSOUNDEX", 0, 0, 0, 0 },
46479 { "GETSFXCOMPLETION", 1, 0, 0, 0 },
46480 { "ENHCROSSFADE", 0, 0, 0, 0 },
46481 { "RESRVD_OP_MOOSH_08", 0, 0, 0, 0 },
46482 { "RESRVD_OP_MOOSH_09", 0, 0, 0, 0 },
46483 { "RESRVD_OP_MOOSH_10", 0, 0, 0, 0 },
46484
46485 { "SUBDATA_SWAP_PAGES", 0, 0, 0, 0 },
46486 { "SUBPAGE_FIND_WIDGET", 0, 0, 0, 0 },
46487 { "SUBPAGE_MOVE_SEL", 0, 0, 0, 0 },
46488 { "SUBPAGE_SWAP_WIDG", 0, 0, 0, 0 },
46489 { "SUBPAGE_NEW_WIDG", 0, 0, 0, 0 },
46490 { "SUBPAGE_DELETE", 0, 0, 0, 0 },
46491 { "SUBWIDG_GET_SELTEXT_OVERRIDE", 1, 0, 0, 0 },
46492 { "SUBWIDG_SET_SELTEXT_OVERRIDE", 1, 0, 0, 0 },
46493 { "SUBWIDG_TY_GETTEXT", 1, 0, 0, 0 },
46494 { "SUBWIDG_TY_SETTEXT", 1, 0, 0, 0 },
46495
46496 { "SUBPAGE_FIND_WIDGET_BY_LABEL", 0, 0, 0, 0 },
46497
46498 { "SUBWIDG_GET_LABEL", 1, 0, 0, 0 },
46499 { "SUBWIDG_SET_LABEL", 1, 0, 0, 0 },
46500
46501 { "", 0, 0, 0, 0 }
46502 };
46503
46504
46505 script_variable ZASMVars[]=
46506 {
46507 //name id maxcount multiple
46508 { "D", D(0), 8, 0 },
46509 { "A", A(0), 2, 0 },
46510 { "DATA", DATA, 0, 0 },
46511 { "CSET", FCSET, 0, 0 },
46512 { "DELAY", DELAY, 0, 0 },
46513 { "X", FX, 0, 0 },
46514 { "Y", FY, 0, 0 },
46515 { "XD", XD, 0, 0 },
46516 { "YD", YD, 0, 0 },
46517 { "XD2", XD2, 0, 0 },
46518 { "YD2", YD2, 0, 0 },
46519 { "FLAG", FLAG, 0, 0 },
46520 { "WIDTH", WIDTH, 0, 0 },
46521 { "HEIGHT", HEIGHT, 0, 0 },
46522 { "LINK", LINK, 0, 0 },
46523 { "FFFLAGSD", FFFLAGSD, 0, 0 },
46524 { "FFCWIDTH", FFCWIDTH, 0, 0 },
46525 { "FFCHEIGHT", FFCHEIGHT, 0, 0 },
46526 { "FFTWIDTH", FFTWIDTH, 0, 0 },
46527 { "FFTHEIGHT", FFTHEIGHT, 0, 0 },
46528 { "FFLINK", FFLINK, 0, 0 },
46529 // { "COMBOD", COMBOD(0), 176, 3 },
46530 // { "COMBOC", COMBOC(0), 176, 3 },
46531 // { "COMBOF", COMBOF(0), 176, 3 },
46532 { "INPUTSTART", INPUTSTART, 0, 0 },
46533 { "INPUTUP", INPUTUP, 0, 0 },
46534 { "INPUTDOWN", INPUTDOWN, 0, 0 },
46535 { "INPUTLEFT", INPUTLEFT, 0, 0 },
46536 { "INPUTRIGHT", INPUTRIGHT, 0, 0 },
46537 { "INPUTA", INPUTA, 0, 0 },
46538 { "INPUTB", INPUTB, 0, 0 },
46539 { "INPUTL", INPUTL, 0, 0 },
46540 { "INPUTR", INPUTR, 0, 0 },
46541 { "INPUTMOUSEX", INPUTMOUSEX, 0, 0 },
46542 { "INPUTMOUSEY", INPUTMOUSEY, 0, 0 },
46543 { "LINKX", LINKX, 0, 0 },
46544 { "LINKY", LINKY, 0, 0 },
46545 { "LINKZ", LINKZ, 0, 0 },
46546 { "LINKJUMP", LINKJUMP, 0, 0 },
46547 { "LINKDIR", LINKDIR, 0, 0 },
46548 { "LINKHITDIR", LINKHITDIR, 0, 0 },
46549 { "LINKHP", LINKHP, 0, 0 },
46550 { "LINKMP", LINKMP, 0, 0 },
46551 { "LINKMAXHP", LINKMAXHP, 0, 0 },
46552 { "LINKMAXMP", LINKMAXMP, 0, 0 },
46553 { "LINKACTION", LINKACTION, 0, 0 },
46554 { "LINKHELD", LINKHELD, 0, 0 },
46555 { "LINKITEMD", LINKITEMD, 0, 0 },
46556 { "LINKSWORDJINX", LINKSWORDJINX, 0, 0 },
46557 { "LINKITEMJINX", LINKITEMJINX, 0, 0 },
46558 { "LINKDRUNK", LINKDRUNK, 0, 0 },
46559 { "ITEMX", ITEMX, 0, 0 },
46560 { "ITEMY", ITEMY, 0, 0 },
46561 { "ITEMZ", ITEMZ, 0, 0 },
46562 { "ITEMJUMP", ITEMJUMP, 0, 0 },
46563 { "ITEMDRAWTYPE", ITEMDRAWTYPE, 0, 0 },
46564 { "ITEMID", ITEMID, 0, 0 },
46565 { "ITEMTILE", ITEMTILE, 0, 0 },
46566 { "ITEMOTILE", ITEMOTILE, 0, 0 },
46567 { "ITEMCSET", ITEMCSET, 0, 0 },
46568 { "ITEMFLASHCSET", ITEMFLASHCSET, 0, 0 },
46569 { "ITEMFRAMES", ITEMFRAMES, 0, 0 },
46570 { "ITEMFRAME", ITEMFRAME, 0, 0 },
46571 { "ITEMASPEED", ITEMASPEED, 0, 0 },
46572 { "ITEMDELAY", ITEMDELAY, 0, 0 },
46573 { "ITEMFLASH", ITEMFLASH, 0, 0 },
46574 { "ITEMFLIP", ITEMFLIP, 0, 0 },
46575 { "ITEMCOUNT", ITEMCOUNT, 0, 0 },
46576 { "IDATAFAMILY", IDATAFAMILY, 0, 0 },
46577 { "IDATALEVEL", IDATALEVEL, 0, 0 },
46578 { "IDATAKEEP", IDATAKEEP, 0, 0 },
46579 { "IDATAAMOUNT", IDATAAMOUNT, 0, 0 },
46580 { "IDATASETMAX", IDATASETMAX, 0, 0 },
46581 { "IDATAMAX", IDATAMAX, 0, 0 },
46582 { "IDATACOUNTER", IDATACOUNTER, 0, 0 },
46583 { "ITEMEXTEND", ITEMEXTEND, 0, 0 },
46584 { "NPCX", NPCX, 0, 0 },
46585 { "NPCY", NPCY, 0, 0 },
46586 { "NPCZ", NPCZ, 0, 0 },
46587 { "NPCJUMP", NPCJUMP, 0, 0 },
46588 { "NPCDIR", NPCDIR, 0, 0 },
46589 { "NPCRATE", NPCRATE, 0, 0 },
46590 { "NPCSTEP", NPCSTEP, 0, 0 },
46591 { "NPCFRAMERATE", NPCFRAMERATE, 0, 0 },
46592 { "NPCHALTRATE", NPCHALTRATE, 0, 0 },
46593 { "NPCDRAWTYPE", NPCDRAWTYPE, 0, 0 },
46594 { "NPCHP", NPCHP, 0, 0 },
46595 { "NPCID", NPCID, 0, 0 },
46596 { "NPCDP", NPCDP, 0, 0 },
46597 { "NPCWDP", NPCWDP, 0, 0 },
46598 { "NPCOTILE", NPCOTILE, 0, 0 },
46599 { "NPCENEMY", NPCENEMY, 0, 0 },
46600 { "NPCWEAPON", NPCWEAPON, 0, 0 },
46601 { "NPCITEMSET", NPCITEMSET, 0, 0 },
46602 { "NPCCSET", NPCCSET, 0, 0 },
46603 { "NPCBOSSPAL", NPCBOSSPAL, 0, 0 },
46604 { "NPCBGSFX", NPCBGSFX, 0, 0 },
46605 { "NPCCOUNT", NPCCOUNT, 0, 0 },
46606 { "GD", GD(0), 1024, 0 },
46607 { "SDD", SDD, 0, 0 },
46608 { "GDD", GDD, 0, 0 },
46609 { "SDDD", SDDD, 0, 0 },
46610 { "SCRDOORD", SCRDOORD, 0, 0 },
46611 { "GAMEDEATHS", GAMEDEATHS, 0, 0 },
46612 { "GAMECHEAT", GAMECHEAT, 0, 0 },
46613 { "GAMETIME", GAMETIME, 0, 0 },
46614 { "GAMEHASPLAYED", GAMEHASPLAYED, 0, 0 },
46615 { "GAMETIMEVALID", GAMETIMEVALID, 0, 0 },
46616 { "GAMEGUYCOUNT", GAMEGUYCOUNT, 0, 0 },
46617 { "GAMECONTSCR", GAMECONTSCR, 0, 0 },
46618 { "GAMECONTDMAP", GAMECONTDMAP, 0, 0 },
46619 { "GAMECOUNTERD", GAMECOUNTERD, 0, 0 },
46620 { "GAMEMCOUNTERD", GAMEMCOUNTERD, 0, 0 },
46621 { "GAMEDCOUNTERD", GAMEDCOUNTERD, 0, 0 },
46622 { "GAMEGENERICD", GAMEGENERICD, 0, 0 },
46623 { "GAMEMISC", GAMEMISC, 0, 0 },
46624 { "GAMEITEMSD", GAMEITEMSD, 0, 0 },
46625 { "GAMELITEMSD", GAMELITEMSD, 0, 0 },
46626 { "GAMELKEYSD", GAMELKEYSD, 0, 0 },
46627 { "SCREENSTATED", SCREENSTATED, 0, 0 },
46628 { "SCREENSTATEDD", SCREENSTATEDD, 0, 0 },
46629 { "GAMEGUYCOUNTD", GAMEGUYCOUNTD, 0, 0 },
46630 { "CURMAP", CURMAP, 0, 0 },
46631 { "CURSCR", CURSCR, 0, 0 },
46632 { "CURDSCR", CURDSCR, 0, 0 },
46633 { "CURDMAP", CURDMAP, 0, 0 },
46634 { "COMBODD", COMBODD, 0, 0 },
46635 { "COMBOCD", COMBOCD, 0, 0 },
46636 { "COMBOFD", COMBOFD, 0, 0 },
46637 { "COMBOTD", COMBOTD, 0, 0 },
46638 { "COMBOID", COMBOID, 0, 0 },
46639 { "COMBOSD", COMBOSD, 0, 0 },
46640 { "REFITEMCLASS", REFITEMCLASS, 0, 0 },
46641 { "REFITEM", REFITEM, 0, 0 },
46642 { "REFFFC", REFFFC, 0, 0 },
46643 { "REFLWPN", REFLWPN, 0, 0 },
46644 { "REFEWPN", REFEWPN, 0, 0 },
46645 { "REFLWPNCLASS", REFLWPNCLASS, 0, 0 },
46646 { "REFEWPNCLASS", REFEWPNCLASS, 0, 0 },
46647 { "REFNPC", REFNPC, 0, 0 },
46648 { "REFNPCCLASS", REFNPCCLASS, 0, 0 },
46649 { "LWPNX", LWPNX, 0, 0 },
46650 { "LWPNY", LWPNY, 0, 0 },
46651 { "LWPNZ", LWPNZ, 0, 0 },
46652 { "LWPNJUMP", LWPNJUMP, 0, 0 },
46653 { "LWPNDIR", LWPNDIR, 0, 0 },
46654 { "LWPNSTEP", LWPNSTEP, 0, 0 },
46655 { "LWPNANGULAR", LWPNANGULAR, 0, 0 },
46656 { "LWPNANGLE", LWPNANGLE, 0, 0 },
46657 { "LWPNDRAWTYPE", LWPNDRAWTYPE, 0, 0 },
46658 { "LWPNPOWER", LWPNPOWER, 0, 0 },
46659 { "LWPNDEAD", LWPNDEAD, 0, 0 },
46660 { "LWPNID", LWPNID, 0, 0 },
46661 { "LWPNTILE", LWPNTILE, 0, 0 },
46662 { "LWPNCSET", LWPNCSET, 0, 0 },
46663 { "LWPNFLASHCSET", LWPNFLASHCSET, 0, 0 },
46664 { "LWPNFRAMES", LWPNFRAMES, 0, 0 },
46665 { "LWPNFRAME", LWPNFRAME, 0, 0 },
46666 { "LWPNASPEED", LWPNASPEED, 0, 0 },
46667 { "LWPNFLASH", LWPNFLASH, 0, 0 },
46668 { "LWPNFLIP", LWPNFLIP, 0, 0 },
46669 { "LWPNCOUNT", LWPNCOUNT, 0, 0 },
46670 { "LWPNEXTEND", LWPNEXTEND, 0, 0 },
46671 { "LWPNOTILE", LWPNOTILE, 0, 0 },
46672 { "LWPNOCSET", LWPNOCSET, 0, 0 },
46673 { "EWPNX", EWPNX, 0, 0 },
46674 { "EWPNY", EWPNY, 0, 0 },
46675 { "EWPNZ", EWPNZ, 0, 0 },
46676 { "EWPNJUMP", EWPNJUMP, 0, 0 },
46677 { "EWPNDIR", EWPNDIR, 0, 0 },
46678 { "EWPNSTEP", EWPNSTEP, 0, 0 },
46679 { "EWPNANGULAR", EWPNANGULAR, 0, 0 },
46680 { "EWPNANGLE", EWPNANGLE, 0, 0 },
46681 { "EWPNDRAWTYPE", EWPNDRAWTYPE, 0, 0 },
46682 { "EWPNPOWER", EWPNPOWER, 0, 0 },
46683 { "EWPNDEAD", EWPNDEAD, 0, 0 },
46684 { "EWPNID", EWPNID, 0, 0 },
46685 { "EWPNTILE", EWPNTILE, 0, 0 },
46686 { "EWPNCSET", EWPNCSET, 0, 0 },
46687 { "EWPNFLASHCSET", EWPNFLASHCSET, 0, 0 },
46688 { "EWPNFRAMES", EWPNFRAMES, 0, 0 },
46689 { "EWPNFRAME", EWPNFRAME, 0, 0 },
46690 { "EWPNASPEED", EWPNASPEED, 0, 0 },
46691 { "EWPNFLASH", EWPNFLASH, 0, 0 },
46692 { "EWPNFLIP", EWPNFLIP, 0, 0 },
46693 { "EWPNCOUNT", EWPNCOUNT, 0, 0 },
46694 { "EWPNEXTEND", EWPNEXTEND, 0, 0 },
46695 { "EWPNOTILE", EWPNOTILE, 0, 0 },
46696 { "EWPNOCSET", EWPNOCSET, 0, 0 },
46697 { "NPCEXTEND", NPCEXTEND, 0, 0 },
46698 { "SP", SP, 0, 0 },
46699 { "SP", SP, 0, 0 },
46700 { "WAVY", WAVY, 0, 0 },
46701 { "QUAKE", QUAKE, 0, 0 },
46702 { "IDATAUSESOUND", IDATAUSESOUND, 0, 0 },
46703 { "INPUTMOUSEZ", INPUTMOUSEZ, 0, 0 },
46704 { "INPUTMOUSEB", INPUTMOUSEB, 0, 0 },
46705 { "COMBODDM", COMBODDM, 0, 0 },
46706 { "COMBOCDM", COMBOCDM, 0, 0 },
46707 { "COMBOFDM", COMBOFDM, 0, 0 },
46708 { "COMBOTDM", COMBOTDM, 0, 0 },
46709 { "COMBOIDM", COMBOIDM, 0, 0 },
46710 { "COMBOSDM", COMBOSDM, 0, 0 },
46711 { "SCRIPTRAM", SCRIPTRAM, 0, 0 },
46712 { "GLOBALRAM", GLOBALRAM, 0, 0 },
46713 { "SCRIPTRAMD", SCRIPTRAMD, 0, 0 },
46714 { "GLOBALRAMD", GLOBALRAMD, 0, 0 },
46715 { "LWPNHXOFS", LWPNHXOFS, 0, 0 },
46716 { "LWPNHYOFS", LWPNHYOFS, 0, 0 },
46717 { "LWPNXOFS", LWPNXOFS, 0, 0 },
46718 { "LWPNYOFS", LWPNYOFS, 0, 0 },
46719 { "LWPNZOFS", LWPNZOFS, 0, 0 },
46720 { "LWPNHXSZ", LWPNHXSZ, 0, 0 },
46721 { "LWPNHYSZ", LWPNHYSZ, 0, 0 },
46722 { "LWPNHZSZ", LWPNHZSZ, 0, 0 },
46723 { "EWPNHXOFS", EWPNHXOFS, 0, 0 },
46724 { "EWPNHYOFS", EWPNHYOFS, 0, 0 },
46725 { "EWPNXOFS", EWPNXOFS, 0, 0 },
46726 { "EWPNYOFS", EWPNYOFS, 0, 0 },
46727 { "EWPNZOFS", EWPNZOFS, 0, 0 },
46728 { "EWPNHXSZ", EWPNHXSZ, 0, 0 },
46729 { "EWPNHYSZ", EWPNHYSZ, 0, 0 },
46730 { "EWPNHZSZ", EWPNHZSZ, 0, 0 },
46731 { "NPCHXOFS", NPCHXOFS, 0, 0 },
46732 { "NPCHYOFS", NPCHYOFS, 0, 0 },
46733 { "NPCXOFS", NPCXOFS, 0, 0 },
46734 { "NPCYOFS", NPCYOFS, 0, 0 },
46735 { "NPCZOFS", NPCZOFS, 0, 0 },
46736 { "NPCHXSZ", NPCHXSZ, 0, 0 },
46737 { "NPCHYSZ", NPCHYSZ, 0, 0 },
46738 { "NPCHZSZ", NPCHZSZ, 0, 0 },
46739 { "ITEMHXOFS", ITEMHXOFS, 0, 0 },
46740 { "ITEMHYOFS", ITEMHYOFS, 0, 0 },
46741 { "ITEMXOFS", ITEMXOFS, 0, 0 },
46742 { "ITEMYOFS", ITEMYOFS, 0, 0 },
46743 { "ITEMZOFS", ITEMZOFS, 0, 0 },
46744 { "ITEMHXSZ", ITEMHXSZ, 0, 0 },
46745 { "ITEMHYSZ", ITEMHYSZ, 0, 0 },
46746 { "ITEMHZSZ", ITEMHZSZ, 0, 0 },
46747 { "LWPNTXSZ", LWPNTXSZ, 0, 0 },
46748 { "LWPNTYSZ", LWPNTYSZ, 0, 0 },
46749 { "EWPNTXSZ", EWPNTXSZ, 0, 0 },
46750 { "EWPNTYSZ", EWPNTYSZ, 0, 0 },
46751 { "NPCTXSZ", NPCTXSZ, 0, 0 },
46752 { "NPCTYSZ", NPCTYSZ, 0, 0 },
46753 { "ITEMTXSZ", ITEMTXSZ, 0, 0 },
46754 { "ITEMTYSZ", ITEMTYSZ, 0, 0 },
46755 { "LINKHXOFS", LINKHXOFS, 0, 0 },
46756 { "LINKHYOFS", LINKHYOFS, 0, 0 },
46757 { "LINKXOFS", LINKXOFS, 0, 0 },
46758 { "LINKYOFS", LINKYOFS, 0, 0 },
46759 { "LINKZOFS", LINKZOFS, 0, 0 },
46760 { "LINKHXSZ", LINKHXSZ, 0, 0 },
46761 { "LINKHYSZ", LINKHYSZ, 0, 0 },
46762 { "LINKHZSZ", LINKHZSZ, 0, 0 },
46763 { "LINKTXSZ", LINKTXSZ, 0, 0 },
46764 { "LINKTYSZ", LINKTYSZ, 0, 0 },
46765 { "NPCTILE", NPCTILE, 0, 0 },
46766 { "LWPNBEHIND", LWPNBEHIND, 0, 0 },
46767 { "EWPNBEHIND", EWPNBEHIND, 0, 0 },
46768 { "SDDDD", SDDDD, 0, 0 },
46769 { "CURLEVEL", CURLEVEL, 0, 0 },
46770 { "ITEMPICKUP", ITEMPICKUP, 0, 0 },
46771 { "INPUTMAP", INPUTMAP, 0, 0 },
46772 { "LIT", LIT, 0, 0 },
46773 { "INPUTEX1", INPUTEX1, 0, 0 },
46774 { "INPUTEX2", INPUTEX2, 0, 0 },
46775 { "INPUTEX3", INPUTEX3, 0, 0 },
46776 { "INPUTEX4", INPUTEX4, 0, 0 },
46777 { "INPUTPRESSSTART", INPUTPRESSSTART, 0, 0 },
46778 { "INPUTPRESSUP", INPUTPRESSUP, 0, 0 },
46779 { "INPUTPRESSDOWN", INPUTPRESSDOWN, 0, 0 },
46780 { "INPUTPRESSLEFT", INPUTPRESSLEFT, 0, 0 },
46781 { "INPUTPRESSRIGHT", INPUTPRESSRIGHT, 0, 0 },
46782 { "INPUTPRESSA", INPUTPRESSA, 0, 0 },
46783 { "INPUTPRESSB", INPUTPRESSB, 0, 0 },
46784 { "INPUTPRESSL", INPUTPRESSL, 0, 0 },
46785 { "INPUTPRESSR", INPUTPRESSR, 0, 0 },
46786 { "INPUTPRESSEX1", INPUTPRESSEX1, 0, 0 },
46787 { "INPUTPRESSEX2", INPUTPRESSEX2, 0, 0 },
46788 { "INPUTPRESSEX3", INPUTPRESSEX3, 0, 0 },
46789 { "INPUTPRESSEX4", INPUTPRESSEX4, 0, 0 },
46790 { "LWPNMISCD", LWPNMISCD, 0, 0 },
46791 { "EWPNMISCD", EWPNMISCD, 0, 0 },
46792 { "NPCMISCD", NPCMISCD, 0, 0 },
46793 { "ITEMMISCD", ITEMMISCD, 0, 0 },
46794 { "FFMISCD", FFMISCD, 0, 0 },
46795 { "GETMIDI", GETMIDI, 0, 0 },
46796 { "NPCHOMING", NPCHOMING, 0, 0 },
46797 { "NPCDD", NPCDD, 0, 0 },
46798 { "LINKEQUIP", LINKEQUIP, 0, 0 },
46799 { "INPUTAXISUP", INPUTAXISUP, 0, 0 },
46800 { "INPUTAXISDOWN", INPUTAXISDOWN, 0, 0 },
46801 { "INPUTAXISLEFT", INPUTAXISLEFT, 0, 0 },
46802 { "INPUTAXISRIGHT", INPUTAXISRIGHT, 0, 0 },
46803 { "PRESSAXISUP", INPUTPRESSAXISUP, 0, 0 },
46804 { "PRESSAXISDOWN", INPUTPRESSAXISDOWN, 0, 0 },
46805 { "PRESSAXISLEFT", INPUTPRESSAXISLEFT, 0, 0 },
46806 { "PRESSAXISRIGHT", INPUTPRESSAXISRIGHT, 0, 0 },
46807 { "NPCTYPE", NPCTYPE, 0, 0 },
46808 { "FFSCRIPT", FFSCRIPT, 0, 0 },
46809 { "SCREENFLAGSD", SCREENFLAGSD, 0, 0 },
46810 { "LINKINVIS", LINKINVIS, 0, 0 },
46811 { "LINKINVINC", LINKINVINC, 0, 0 },
46812 { "SCREENEFLAGSD", SCREENEFLAGSD, 0, 0 },
46813 { "NPCMFLAGS", NPCMFLAGS, 0, 0 },
46814 { "FFINITDD", FFINITDD, 0, 0 },
46815 { "LINKMISCD", LINKMISCD, 0, 0 },
46816 { "DMAPFLAGSD", DMAPFLAGSD, 0, 0 },
46817 { "LWPNCOLLDET", LWPNCOLLDET, 0, 0 },
46818 { "EWPNCOLLDET", EWPNCOLLDET, 0, 0 },
46819 { "NPCCOLLDET", NPCCOLLDET, 0, 0 },
46820 { "LINKLADDERX", LINKLADDERX, 0, 0 },
46821 { "LINKLADDERY", LINKLADDERY, 0, 0 },
46822 { "NPCSTUN", NPCSTUN, 0, 0 },
46823 { "NPCDEFENSED", NPCDEFENSED, 0, 0 },
46824 { "IDATAPOWER", IDATAPOWER, 0, 0 },
46825 { "DMAPLEVELD", DMAPLEVELD, 0, 0 },
46826 { "DMAPCOMPASSD", DMAPCOMPASSD, 0, 0 },
46827 { "DMAPCONTINUED", DMAPCONTINUED, 0, 0 },
46828 { "DMAPMIDID", DMAPMIDID, 0, 0 },
46829 { "IDATAINITDD", IDATAINITDD, 0, 0 },
46830 { "ROOMTYPE", ROOMTYPE, 0, 0 },
46831 { "ROOMDATA", ROOMDATA, 0, 0 },
46832 { "LINKTILE", LINKTILE, 0, 0 },
46833 { "LINKFLIP", LINKFLIP, 0, 0 },
46834 { "INPUTPRESSMAP", INPUTPRESSMAP, 0, 0 },
46835 { "NPCHUNGER", NPCHUNGER, 0, 0 },
46836 { "GAMESTANDALONE", GAMESTANDALONE, 0, 0 },
46837 { "GAMEENTRSCR", GAMEENTRSCR, 0, 0 },
46838 { "GAMEENTRDMAP", GAMEENTRDMAP, 0, 0 },
46839 { "GAMECLICKFREEZE", GAMECLICKFREEZE, 0, 0 },
46840 { "PUSHBLOCKX", PUSHBLOCKX, 0, 0 },
46841 { "PUSHBLOCKY", PUSHBLOCKY, 0, 0 },
46842 { "PUSHBLOCKCOMBO", PUSHBLOCKCOMBO, 0, 0 },
46843 { "PUSHBLOCKCSET", PUSHBLOCKCSET, 0, 0 },
46844 { "UNDERCOMBO", UNDERCOMBO, 0, 0 },
46845 { "UNDERCSET", UNDERCSET, 0, 0 },
46846 { "DMAPOFFSET", DMAPOFFSET, 0, 0 },
46847 { "DMAPMAP", DMAPMAP, 0, 0 },
46848 { "__RESERVED_FOR_GAMETHROTTLE", __RESERVED_FOR_GAMETHROTTLE, 0, 0 },
46849 { "REFMAPDATA", REFMAPDATA, 0, 0 },
46850 { "REFSCREENDATA", REFSCREENDATA, 0, 0 },
46851 { "REFCOMBODATA", REFCOMBODATA, 0, 0 },
46852 { "REFSPRITEDATA", REFSPRITEDATA, 0, 0 },
46853 { "REFBITMAP", REFBITMAP, 0, 0 },
46854 { "REFDMAPDATA", REFDMAPDATA, 0, 0 },
46855 { "REFSHOPDATA", REFSHOPDATA, 0, 0 },
46856 { "REFMSGDATA", REFMSGDATA, 0, 0 },
46857 { "REFUNTYPED", REFUNTYPED, 0, 0 },
46858 { "REFDROPS", REFDROPS, 0, 0 },
46859 { "REFPONDS", REFPONDS, 0, 0 },
46860 { "REFWARPRINGS", REFWARPRINGS, 0, 0 },
46861 { "REFDOORS", REFDOORS, 0, 0 },
46862 { "REFUICOLOURS", REFUICOLOURS, 0, 0 },
46863 { "REFRGB", REFRGB, 0, 0 },
46864 { "REFPALETTE", REFPALETTE, 0, 0 },
46865 { "REFTUNES", REFTUNES, 0, 0 },
46866 { "REFPALCYCLE", REFPALCYCLE, 0, 0 },
46867 { "REFGAMEDATA", REFGAMEDATA, 0, 0 },
46868 { "REFCHEATS", REFCHEATS, 0, 0 },
46869 { "IDATAMAGICTIMER", IDATAMAGICTIMER, 0, 0 },
46870 { "IDATALTM", IDATALTM, 0, 0 },
46871 { "IDATASCRIPT", IDATASCRIPT, 0, 0 },
46872 { "IDATAPSCRIPT", IDATAPSCRIPT, 0, 0 },
46873 { "IDATAMAGCOST", IDATAMAGCOST, 0, 0 },
46874 { "IDATAMINHEARTS", IDATAMINHEARTS, 0, 0 },
46875 { "IDATATILE", IDATATILE, 0, 0 },
46876 { "IDATAMISC", IDATAMISC, 0, 0 },
46877 { "IDATACSET", IDATACSET, 0, 0 },
46878 { "IDATAFRAMES", IDATAFRAMES, 0, 0 },
46879 { "IDATAASPEED", IDATAASPEED, 0, 0 },
46880 { "IDATADELAY", IDATADELAY, 0, 0 },
46881 { "IDATACOMBINE", IDATACOMBINE, 0, 0 },
46882 { "IDATADOWNGRADE", IDATADOWNGRADE, 0, 0 },
46883 { "IDATAPSTRING", IDATAPSTRING, 0, 0 },
46884 { "IDATAPFLAGS", IDATAPFLAGS, 0, 0 },
46885 { "IDATAKEEPOLD", IDATAKEEPOLD, 0, 0 },
46886 { "IDATARUPEECOST", IDATARUPEECOST, 0, 0 },
46887 { "IDATAEDIBLE", IDATAEDIBLE, 0, 0 },
46888 { "IDATAFLAGUNUSED", IDATAFLAGUNUSED, 0, 0 },
46889 { "IDATAGAINLOWER", IDATAGAINLOWER, 0, 0 },
46890 { "RESVD0024", RESVD024, 0, 0 },
46891 { "RESVD0025", RESVD025, 0, 0 },
46892 { "RESVD0026", RESVD026, 0, 0 },
46893 { "IDATAID", IDATAID, 0, 0 },
46894 { "__RESERVED_FOR_LINKEXTEND", __RESERVED_FOR_LINKEXTEND, 0, 0 },
46895 { "NPCSCRDEFENSED", NPCSCRDEFENSED, 0, 0 },
46896 { "__RESERVED_FOR_SETLINKTILE", __RESERVED_FOR_SETLINKTILE, 0, 0 },
46897 { "__RESERVED_FOR_SETLINKEXTEND", __RESERVED_FOR_SETLINKEXTEND, 0, 0 },
46898 { "__RESERVED_FOR_SIDEWARPSFX", __RESERVED_FOR_SIDEWARPSFX, 0, 0 },
46899 { "__RESERVED_FOR_PITWARPSFX", __RESERVED_FOR_PITWARPSFX, 0, 0 },
46900 { "__RESERVED_FOR_SIDEWARPVISUAL", __RESERVED_FOR_SIDEWARPVISUAL, 0, 0 },
46901 { "__RESERVED_FOR_PITWARPVISUAL", __RESERVED_FOR_PITWARPVISUAL, 0, 0 },
46902 { "GAMESETA", GAMESETA, 0, 0 },
46903 { "GAMESETB", GAMESETB, 0, 0 },
46904 { "SETITEMSLOT", SETITEMSLOT, 0, 0 },
46905 { "LINKITEMB", LINKITEMB, 0, 0 },
46906 { "LINKITEMA", LINKITEMA, 0, 0 },
46907 { "__RESERVED_FOR_LINKWALKTILE", __RESERVED_FOR_LINKWALKTILE, 0, 0 }, //Walk sprite
46908 { "__RESERVED_FOR_LINKFLOATTILE", __RESERVED_FOR_LINKFLOATTILE, 0, 0 }, //float sprite
46909 { "__RESERVED_FOR_LINKSWIMTILE", __RESERVED_FOR_LINKSWIMTILE, 0, 0 }, //swim sprite
46910 { "__RESERVED_FOR_LINKDIVETILE", __RESERVED_FOR_LINKDIVETILE, 0, 0 }, //dive sprite
46911 { "__RESERVED_FOR_LINKSLASHTILE", __RESERVED_FOR_LINKSLASHTILE, 0, 0 }, //slash sprite
46912 { "__RESERVED_FOR_LINKJUMPTILE", __RESERVED_FOR_LINKJUMPTILE, 0, 0 }, //jump sprite
46913 { "__RESERVED_FOR_LINKCHARGETILE", __RESERVED_FOR_LINKCHARGETILE, 0, 0 }, //charge sprite
46914 { "__RESERVED_FOR_LINKSTABTILE", __RESERVED_FOR_LINKSTABTILE, 0, 0 }, //stab sprite
46915 { "__RESERVED_FOR_LINKCASTTILE", __RESERVED_FOR_LINKCASTTILE, 0, 0 }, //casting sprite
46916 { "__RESERVED_FOR_LINKHOLD1LTILE", __RESERVED_FOR_LINKHOLD1LTILE, 0, 0 }, //hold1land sprite
46917 { "__RESERVED_FOR_LINKHOLD2LTILE", __RESERVED_FOR_LINKHOLD2LTILE, 0, 0 }, //hold2land sprite
46918 { "__RESERVED_FOR_LINKHOLD1WTILE", __RESERVED_FOR_LINKHOLD1WTILE, 0, 0 }, //hold1water sprite
46919 { "__RESERVED_FOR_LINKHOLD2WTILE", __RESERVED_FOR_LINKHOLD2WTILE, 0, 0 }, //hold2water sprite
46920 { "__RESERVED_FOR_LINKPOUNDTILE", __RESERVED_FOR_LINKPOUNDTILE, 0, 0 }, //hammer pound sprite
46921 { "__RESERVED_FOR_LINKSWIMSPD", __RESERVED_FOR_LINKSWIMSPD, 0, 0 },
46922 { "__RESERVED_FOR_LINKWALKANMSPD", __RESERVED_FOR_LINKWALKANMSPD, 0, 0 },
46923 { "__RESERVED_FOR_LINKANIMTYPE", __RESERVED_FOR_LINKANIMTYPE, 0, 0 },
46924 { "LINKINVFRAME", LINKINVFRAME, 0, 0 },
46925 { "LINKCANFLICKER", LINKCANFLICKER, 0, 0 },
46926 { "LINKHURTSFX", LINKHURTSFX, 0, 0 },
46927 { "NOACTIVESUBSC", NOACTIVESUBSC, 0, 0 },
46928 { "LWPNRANGE", LWPNRANGE, 0, 0 },
46929 { "ZELDAVERSION", ZELDAVERSION, 0, 0 },
46930 { "ZELDABUILD", ZELDABUILD, 0, 0 },
46931 { "ZELDABETA", ZELDABETA, 0, 0 },
46932 { "NPCINVINC", NPCINVINC, 0, 0 },
46933 { "NPCSUPERMAN", NPCSUPERMAN, 0, 0 },
46934 { "NPCHASITEM", NPCHASITEM, 0, 0 },
46935 { "NPCRINGLEAD", NPCRINGLEAD, 0, 0 },
46936 { "IDATAFRAME", IDATAFRAME, 0, 0 },
46937 { "ITEMACLK", ITEMACLK, 0, 0 },
46938 { "FFCID", FFCID, 0, 0 },
46939 { "IDATAATTRIB", IDATAATTRIB, 0, 0 },
46940 { "IDATASPRITE", IDATASPRITE, 0, 0 },
46941 { "IDATAFLAGS", IDATAFLAGS, 0, 0 },
46942 { "DMAPLEVELPAL", DMAPLEVELPAL, 0, 0 },
46943 { "__RESERVED_FOR_ITEMPTR", __RESERVED_FOR_ITEMPTR, 0, 0 },
46944 { "__RESERVED_FOR_NPCPTR", __RESERVED_FOR_NPCPTR, 0, 0 },
46945 { "__RESERVED_FOR_LWPNPTR", __RESERVED_FOR_LWPNPTR, 0, 0 },
46946 { "__RESERVED_FOR_EWPNPTR", __RESERVED_FOR_EWPNPTR, 0, 0 },
46947 { "SETSCREENDOOR", SETSCREENDOOR, 0, 0 },
46948 { "SETSCREENENEMY", SETSCREENENEMY, 0, 0 },
46949 { "GAMEMAXMAPS", GAMEMAXMAPS, 0, 0 },
46950 { "CREATELWPNDX", CREATELWPNDX, 0, 0 },
46951 { "__RESERVED_FOR_SCREENFLAG", __RESERVED_FOR_SCREENFLAG, 0, 0 },
46952 { "BUTTONPRESS", BUTTONPRESS, 0, 0 },
46953 { "BUTTONINPUT", BUTTONINPUT, 0, 0 },
46954 { "BUTTONHELD", BUTTONHELD, 0, 0 },
46955 { "RAWKEY", RAWKEY, 0, 0 },
46956 { "READKEY", READKEY, 0, 0 },
46957 { "JOYPADPRESS", JOYPADPRESS, 0, 0 },
46958 { "DISABLEDITEM", DISABLEDITEM, 0, 0 },
46959 { "LINKDIAG", LINKDIAG, 0, 0 },
46960 { "LINKBIGHITBOX", LINKBIGHITBOX, 0, 0 },
46961 { "LINKEATEN", LINKEATEN, 0, 0 },
46962 { "__RESERVED_FOR_LINKRETSQUARE", __RESERVED_FOR_LINKRETSQUARE, 0, 0 },
46963 { "__RESERVED_FOR_LINKWARPSOUND", __RESERVED_FOR_LINKWARPSOUND, 0, 0 },
46964 { "__RESERVED_FOR_PLAYPITWARPSFX", __RESERVED_FOR_PLAYPITWARPSFX, 0, 0 },
46965 { "__RESERVED_FOR_WARPEFFECT", __RESERVED_FOR_WARPEFFECT, 0, 0 },
46966 { "__RESERVED_FOR_PLAYWARPSOUND", __RESERVED_FOR_PLAYWARPSOUND, 0, 0 },
46967 { "LINKUSINGITEM", LINKUSINGITEM, 0, 0 },
46968 { "LINKUSINGITEMA", LINKUSINGITEMA, 0, 0 },
46969 { "LINKUSINGITEMB", LINKUSINGITEMB, 0, 0 },
46970 // { "DMAPLEVELPAL", DMAPLEVELPAL, 0, 0 },
46971 // { "LINKZHEIGHT", LINKZHEIGHT, 0, 0 },
46972 // { "ITEMINDEX", ITEMINDEX, 0, 0 },
46973 // { "LWPNINDEX", LWPNINDEX, 0, 0 },
46974 // { "EWPNINDEX", EWPNINDEX, 0, 0 },
46975 // { "NPCINDEX", NPCINDEX, 0, 0 },
46976 //TABLE END
46977 { "IDATAUSEWPN", IDATAUSEWPN, 0, 0 }, //UseWeapon
46978 { "IDATAUSEDEF", IDATAUSEDEF, 0, 0 }, //UseDefense
46979 { "IDATAWRANGE", IDATAWRANGE, 0, 0 }, //Range
46980 { "IDATAUSEMVT", IDATAUSEMVT, 0, 0 }, //Movement[]
46981 { "IDATADURATION", IDATADURATION, 0, 0 }, //Duration
46982
46983 { "IDATADUPLICATES", IDATADUPLICATES, 0, 0 }, //Duplicates
46984 { "IDATADRAWLAYER", IDATADRAWLAYER, 0, 0 }, //DrawLayer
46985 { "IDATACOLLECTFLAGS", IDATACOLLECTFLAGS, 0, 0 }, //CollectFlags
46986 { "IDATAWEAPONSCRIPT", IDATAWEAPONSCRIPT, 0, 0 }, //WeaponScript
46987 { "IDATAMISCD", IDATAMISCD, 0, 0 }, //WeaponMisc[32]
46988 { "IDATAWEAPHXOFS", IDATAWEAPHXOFS, 0, 0 }, //WeaponHitXOffset
46989 { "IDATAWEAPHYOFS", IDATAWEAPHYOFS, 0, 0 }, //WeaponHitYOffset
46990 { "IDATAWEAPHXSZ", IDATAWEAPHYSZ, 0, 0 }, //WeaponHitWidth
46991 { "IDATAWEAPHYSZ", IDATAWEAPHYSZ, 0, 0 }, //WeaponHitHeight
46992 { "IDATAWEAPHZSZ", IDATAWEAPHZSZ, 0, 0 }, //WeaponHitZHeight
46993 { "IDATAWEAPXOFS", IDATAWEAPXOFS, 0, 0 }, //WeaponDrawXOffset
46994 { "IDATAWEAPYOFS", IDATAWEAPYOFS, 0, 0 }, //WeaponDrawYOffset
46995 { "IDATAWEAPZOFS", IDATAWEAPZOFS, 0, 0 }, //WeaponDrawZOffset
46996 { "IDATAWPNINITD", IDATAWPNINITD, 0, 0 }, //WeaponD[8]
46997
46998 { "NPCWEAPSPRITE", NPCWEAPSPRITE, 0, 0 }, //WeaponSprite
46999
47000 { "DEBUGREFFFC", DEBUGREFFFC, 0, 0 }, //REFFFC
47001 { "DEBUGREFITEM", DEBUGREFITEM, 0, 0 }, //REFITEM
47002 { "DEBUGREFNPC", DEBUGREFNPC, 0, 0 }, //REFNPC
47003 { "DEBUGREFITEMDATA", DEBUGREFITEMDATA, 0, 0 }, //REFITEMCLASS
47004 { "DEBUGREFLWEAPON", DEBUGREFLWEAPON, 0, 0 }, //REFLWPN
47005 { "DEBUGREFEWEAPON", DEBUGREFEWEAPON, 0, 0 }, //REFEWPN
47006 { "DEBUGSP", DEBUGSP, 0, 0 }, //SP
47007 { "DEBUGGDR", DEBUGGDR, 0, 0 }, //GDR[256]
47008 { "SCREENWIDTH", SCREENWIDTH, 0, 0 },
47009 { "SCREENHEIGHT", SCREENHEIGHT, 0, 0 },
47010 { "SCREENVIEWX", SCREENVIEWX, 0, 0 },
47011 { "SCREENVIEWY", SCREENVIEWY, 0, 0 },
47012 { "SCREENGUY", SCREENGUY, 0, 0 },
47013 { "SCREENSTRING", SCREENSTRING, 0, 0 },
47014 { "SCREENROOM", SCREENROOM, 0, 0 },
47015 { "SCREENENTX", SCREENENTX, 0, 0 },
47016 { "SCREENENTY", SCREENENTY, 0, 0 },
47017 { "SCREENITEM", SCREENITEM, 0, 0 },
47018 { "SCREENUNDCMB", SCREENUNDCMB, 0, 0 },
47019 { "SCREENUNDCST", SCREENUNDCST, 0, 0 },
47020 { "SCREENCATCH", SCREENCATCH, 0, 0 },
47021 { "SETSCREENLAYOP", SETSCREENLAYOP, 0, 0 },
47022 { "SETSCREENSECCMB", SETSCREENSECCMB, 0, 0 },
47023 { "SETSCREENSECCST", SETSCREENSECCST, 0, 0 },
47024 { "SETSCREENSECFLG", SETSCREENSECFLG, 0, 0 },
47025 { "SETSCREENLAYMAP", SETSCREENLAYMAP, 0, 0 },
47026 { "SETSCREENLAYSCR", SETSCREENLAYSCR, 0, 0 },
47027 { "SETSCREENPATH", SETSCREENPATH, 0, 0 },
47028 { "SETSCREENWARPRX", SETSCREENWARPRX, 0, 0 },
47029 { "SETSCREENWARPRY", SETSCREENWARPRY, 0, 0 },
47030 {"GAMENUMMESSAGES", GAMENUMMESSAGES, 0, 0 },
47031 {"GAMESUBSCHEIGHT", GAMESUBSCHEIGHT, 0, 0 },
47032 {"GAMEPLAYFIELDOFS", GAMEPLAYFIELDOFS, 0, 0 },
47033 {"PASSSUBOFS", PASSSUBOFS, 0, 0 }, //
47034
47035
47036 //NPCData
47037 {"SETNPCDATASCRIPTDEF", SETNPCDATASCRIPTDEF, 0, 0 },
47038 {"SETNPCDATADEFENSE", SETNPCDATADEFENSE, 0, 0 },
47039 {"SETNPCDATASIZEFLAG", SETNPCDATASIZEFLAG, 0, 0 },
47040 {"SETNPCDATAATTRIBUTE", SETNPCDATAATTRIBUTE, 0, 0 },
47041
47042 {"SCDBLOCKWEAPON", SCDBLOCKWEAPON, 0, 0 },
47043 {"SCDSTRIKEWEAPONS", SCDSTRIKEWEAPONS, 0, 0 },
47044 {"SCDEXPANSION", SCDEXPANSION, 0, 0 },
47045 {"SETGAMEOVERELEMENT", SETGAMEOVERELEMENT, 0, 0 },
47046 {"SETGAMEOVERSTRING", SETGAMEOVERSTRING, 0, 0 },
47047 {"MOUSEARR", MOUSEARR, 0, 0 },
47048
47049 {"IDATAOVERRIDEFLWEAP", IDATAOVERRIDEFLWEAP, 0, 0 },
47050 {"IDATATILEHWEAP", IDATATILEHWEAP, 0, 0 },
47051 {"IDATATILEWWEAP", IDATATILEWWEAP, 0, 0 },
47052 {"IDATAHZSZWEAP", IDATAHZSZWEAP, 0, 0 },
47053 {"IDATAHYSZWEAP", IDATAHYSZWEAP, 0, 0 },
47054 {"IDATAHXSZWEAP", IDATAHXSZWEAP, 0, 0 },
47055 {"IDATADYOFSWEAP", IDATADYOFSWEAP, 0, 0 },
47056 {"IDATADXOFSWEAP", IDATADXOFSWEAP, 0, 0 },
47057 {"IDATAHYOFSWEAP", IDATAHYOFSWEAP, 0, 0 },
47058 {"IDATAHXOFSWEAP", IDATAHXOFSWEAP, 0, 0 },
47059 {"IDATAOVERRIDEFL", IDATAOVERRIDEFL, 0, 0 },
47060 {"IDATAPICKUP", IDATAPICKUP, 0, 0 },
47061 {"IDATATILEH", IDATATILEH, 0, 0 },
47062 {"IDATATILEW", IDATATILEW, 0, 0 },
47063 {"IDATAHZSZ", IDATAHZSZ, 0, 0 },
47064 {"IDATAHYSZ", IDATAHYSZ, 0, 0 },
47065 {"IDATAHXSZ", IDATAHXSZ, 0, 0 },
47066 {"IDATADYOFS", IDATADYOFS, 0, 0 },
47067 {"IDATADXOFS", IDATADXOFS, 0, 0 },
47068 {"IDATAHYOFS", IDATAHYOFS, 0, 0 },
47069 {"IDATAHXOFS", IDATAHXOFS, 0, 0 },
47070 //spritedata sd->
47071 {"SPRITEDATATILE", SPRITEDATATILE, 0, 0 },
47072 {"SPRITEDATAMISC", SPRITEDATAMISC, 0, 0 },
47073 {"SPRITEDATACSETS", SPRITEDATACSETS, 0, 0 },
47074 {"SPRITEDATAFRAMES", SPRITEDATAFRAMES, 0, 0 },
47075 {"SPRITEDATASPEED", SPRITEDATASPEED, 0, 0 },
47076 {"SPRITEDATATYPE", SPRITEDATATYPE, 0, 0 },
47077
47078 //npcdata nd->
47079 {"NPCDATATILE", NPCDATATILE, 0, 0 },
47080 {"NPCDATAHEIGHT", NPCDATAHEIGHT, 0, 0 },
47081 {"NPCDATAFLAGS", NPCDATAFLAGS, 0, 0 },
47082 {"NPCDATAFLAGS2", NPCDATAFLAGS2, 0, 0 },
47083 {"NPCDATAWIDTH", NPCDATAWIDTH, 0, 0 },
47084 {"NPCDATAHITSFX", NPCDATAHITSFX, 0, 0 },
47085 {"NPCDATASTILE", NPCDATASTILE, 0, 0 },
47086 {"NPCDATASWIDTH", NPCDATASWIDTH, 0, 0 },
47087 {"NPCDATASHEIGHT", NPCDATASHEIGHT, 0, 0 },
47088 {"NPCDATAETILE", NPCDATAETILE, 0, 0 },
47089 {"NPCDATAEWIDTH", NPCDATAEWIDTH, 0, 0 },
47090 {"NPCDATAEHEIGHT", NPCDATAEHEIGHT, 0, 0 },
47091 {"NPCDATAHP", NPCDATAHP, 0, 0 },
47092 {"NPCDATAFAMILY", NPCDATAFAMILY, 0, 0 },
47093 {"NPCDATACSET", NPCDATACSET, 0, 0 },
47094 {"NPCDATAANIM", NPCDATAANIM, 0, 0 },
47095 {"NPCDATAEANIM", NPCDATAEANIM, 0, 0 },
47096 {"NPCDATAFRAMERATE", NPCDATAFRAMERATE, 0, 0 },
47097 {"NPCDATAEFRAMERATE", NPCDATAEFRAMERATE, 0, 0 },
47098 {"NPCDATATOUCHDAMAGE", NPCDATATOUCHDAMAGE, 0, 0 },
47099 {"NPCDATAWEAPONDAMAGE", NPCDATAWEAPONDAMAGE, 0, 0 },
47100 {"NPCDATAWEAPON", NPCDATAWEAPON, 0, 0 },
47101 {"NPCDATARANDOM", NPCDATARANDOM, 0, 0 },
47102 {"NPCDATAHALT", NPCDATAHALT, 0, 0 },
47103 {"NPCDATASTEP", NPCDATASTEP, 0, 0 },
47104 {"NPCDATAHOMING", NPCDATAHOMING, 0, 0 },
47105 {"NPCDATAHUNGER", NPCDATAHUNGER, 0, 0 },
47106 {"NPCDATADROPSET", NPCDATADROPSET, 0, 0 },
47107 {"NPCDATABGSFX", NPCDATABGSFX, 0, 0 },
47108 {"NPCDATADEATHSFX", NPCDATADEATHSFX, 0, 0 },
47109 {"NPCDATAXOFS", NPCDATAXOFS, 0, 0 },
47110 {"NPCDATAYOFS", NPCDATAYOFS, 0, 0 },
47111 {"NPCDATAZOFS", NPCDATAZOFS, 0, 0 },
47112 {"NPCDATAHXOFS", NPCDATAHXOFS, 0, 0 },
47113 {"NPCDATAHYOFS", NPCDATAHYOFS, 0, 0 },
47114 {"NPCDATAHITWIDTH", NPCDATAHITWIDTH, 0, 0 },
47115 {"NPCDATAHITHEIGHT", NPCDATAHITHEIGHT, 0, 0 },
47116 {"NPCDATAHITZ", NPCDATAHITZ, 0, 0 },
47117 {"NPCDATATILEWIDTH", NPCDATATILEWIDTH, 0, 0 },
47118 {"NPCDATATILEHEIGHT", NPCDATATILEHEIGHT, 0, 0 },
47119 {"NPCDATAWPNSPRITE", NPCDATAWPNSPRITE, 0, 0 },
47120 {"NPCDATADEFENSE", NPCDATADEFENSE, 0, 0 },
47121 {"NPCDATASIZEFLAG", NPCDATASIZEFLAG, 0, 0 },
47122 {"NPCDATAATTRIBUTE", NPCDATAATTRIBUTE, 0, 0 },
47123
47124 {"NPCDATAFROZENTILE", NPCDATAFROZENTILE, 0, 0 },
47125 {"NPCDATAFROZENCSET", NPCDATAFROZENCSET, 0, 0 },
47126
47127 //mapdata md->
47128 {"MAPDATAVALID", MAPDATAVALID, 0, 0 },
47129 {"MAPDATAGUY", MAPDATAGUY, 0, 0 },
47130 {"MAPDATASTRING", MAPDATASTRING, 0, 0 },
47131 {"MAPDATAROOM", MAPDATAROOM, 0, 0 },
47132 {"MAPDATAITEM", MAPDATAITEM, 0, 0 },
47133 {"MAPDATAHASITEM", MAPDATAHASITEM, 0, 0 },
47134 {"MAPDATATILEWARPTYPE", MAPDATATILEWARPTYPE, 0, 0 },
47135 {"MAPDATATILEWARPOVFLAGS", MAPDATATILEWARPOVFLAGS, 0, 0 },
47136 {"MAPDATADOORCOMBOSET", MAPDATADOORCOMBOSET, 0, 0 },
47137 {"MAPDATAWARPRETX", MAPDATAWARPRETX, 0, 0 },
47138 {"MAPDATAWARPRETY", MAPDATAWARPRETY, 0, 0 },
47139 {"MAPDATAWARPRETURNC", MAPDATAWARPRETURNC, 0, 0 },
47140 {"MAPDATASTAIRX", MAPDATASTAIRX, 0, 0 },
47141 {"MAPDATASTAIRY", MAPDATASTAIRY, 0, 0 },
47142 {"MAPDATACOLOUR", MAPDATACOLOUR, 0, 0 },
47143 {"MAPDATAENEMYFLAGS", MAPDATAENEMYFLAGS, 0, 0 },
47144 {"MAPDATADOOR", MAPDATADOOR, 0, 0 },
47145 {"MAPDATATILEWARPDMAP", MAPDATATILEWARPDMAP, 0, 0 },
47146 {"MAPDATATILEWARPSCREEN", MAPDATATILEWARPSCREEN, 0, 0 },
47147 {"MAPDATAEXITDIR", MAPDATAEXITDIR, 0, 0 },
47148 {"MAPDATAENEMY", MAPDATAENEMY, 0, 0 },
47149 {"MAPDATAPATTERN", MAPDATAPATTERN, 0, 0 },
47150 {"MAPDATASIDEWARPTYPE", MAPDATASIDEWARPTYPE, 0, 0 },
47151 {"MAPDATASIDEWARPOVFLAGS", MAPDATASIDEWARPOVFLAGS, 0, 0 },
47152 {"MAPDATAWARPARRIVALX", MAPDATAWARPARRIVALX, 0, 0 },
47153 {"MAPDATAWARPARRIVALY", MAPDATAWARPARRIVALY, 0, 0 },
47154 {"MAPDATAPATH", MAPDATAPATH, 0, 0 },
47155 {"MAPDATASIDEWARPSC", MAPDATASIDEWARPSC, 0, 0 },
47156 {"MAPDATASIDEWARPDMAP", MAPDATASIDEWARPDMAP, 0, 0 },
47157 {"MAPDATASIDEWARPINDEX", MAPDATASIDEWARPINDEX, 0, 0 },
47158 {"MAPDATAUNDERCOMBO", MAPDATAUNDERCOMBO, 0, 0 },
47159 {"MAPDATAUNDERCSET", MAPDATAUNDERCSET, 0, 0 },
47160 {"MAPDATACATCHALL", MAPDATACATCHALL, 0, 0 },
47161 {"MAPDATAFLAGS", MAPDATAFLAGS, 0, 0 },
47162 {"MAPDATACSENSITIVE", MAPDATACSENSITIVE, 0, 0 },
47163 {"MAPDATANORESET", MAPDATANORESET, 0, 0 },
47164 {"MAPDATANOCARRY", MAPDATANOCARRY, 0, 0 },
47165 {"MAPDATALAYERMAP", MAPDATALAYERMAP, 0, 0 },
47166 {"MAPDATALAYERSCREEN", MAPDATALAYERSCREEN, 0, 0 },
47167 {"MAPDATALAYEROPACITY", MAPDATALAYEROPACITY, 0, 0 },
47168 {"MAPDATATIMEDWARPTICS", MAPDATATIMEDWARPTICS, 0, 0 },
47169 {"MAPDATANEXTMAP", MAPDATANEXTMAP, 0, 0 },
47170 {"MAPDATANEXTSCREEN", MAPDATANEXTSCREEN, 0, 0 },
47171 {"MAPDATASECRETCOMBO", MAPDATASECRETCOMBO, 0, 0 },
47172 {"MAPDATASECRETCSET", MAPDATASECRETCSET, 0, 0 },
47173 {"MAPDATASECRETFLAG", MAPDATASECRETFLAG, 0, 0 },
47174 {"MAPDATAVIEWX", MAPDATAVIEWX, 0, 0 },
47175 {"MAPDATAVIEWY", MAPDATAVIEWY, 0, 0 },
47176 {"MAPDATASCREENWIDTH", MAPDATASCREENWIDTH, 0, 0 },
47177 {"MAPDATASCREENHEIGHT", MAPDATASCREENHEIGHT, 0, 0 },
47178 {"MAPDATAENTRYX", MAPDATAENTRYX, 0, 0 },
47179 {"MAPDATAENTRYY", MAPDATAENTRYY, 0, 0 },
47180 {"MAPDATANUMFF", MAPDATANUMFF, 0, 0 },
47181 {"MAPDATAFFDATA", MAPDATAFFDATA, 0, 0 },
47182 {"MAPDATAFFCSET", MAPDATAFFCSET, 0, 0 },
47183 {"MAPDATAFFDELAY", MAPDATAFFDELAY, 0, 0 },
47184 {"MAPDATAFFX", MAPDATAFFX, 0, 0 },
47185 {"MAPDATAFFY", MAPDATAFFY, 0, 0 },
47186 {"MAPDATAFFXDELTA", MAPDATAFFXDELTA, 0, 0 },
47187 {"MAPDATAFFYDELTA", MAPDATAFFYDELTA, 0, 0 },
47188 {"MAPDATAFFXDELTA2", MAPDATAFFXDELTA2, 0, 0 },
47189 {"MAPDATAFFYDELTA2", MAPDATAFFYDELTA2, 0, 0 },
47190 {"MAPDATAFFFLAGS", MAPDATAFFFLAGS, 0, 0 },
47191 {"MAPDATAFFWIDTH", MAPDATAFFWIDTH, 0, 0 },
47192 {"MAPDATAFFHEIGHT", MAPDATAFFHEIGHT, 0, 0 },
47193 {"MAPDATAFFLINK", MAPDATAFFLINK, 0, 0 },
47194 {"MAPDATAFFSCRIPT", MAPDATAFFSCRIPT, 0, 0 },
47195 {"MAPDATAINTID", MAPDATAINTID, 0, 0 }, //Needs to be a function [32][10]
47196 {"MAPDATAINITA", MAPDATAINITA, 0, 0 }, //needs to be a function, [32][2]
47197 {"MAPDATAFFINITIALISED", MAPDATAFFINITIALISED, 0, 0 },
47198 {"MAPDATASCRIPTENTRY", MAPDATASCRIPTENTRY, 0, 0 },
47199 {"MAPDATASCRIPTOCCUPANCY", MAPDATASCRIPTOCCUPANCY, 0, 0 },
47200 {"MAPDATASCRIPTEXIT", MAPDATASCRIPTEXIT, 0, 0 },
47201 {"MAPDATAOCEANSFX", MAPDATAOCEANSFX, 0, 0 },
47202 {"MAPDATABOSSSFX", MAPDATABOSSSFX, 0, 0 },
47203 {"MAPDATASECRETSFX", MAPDATASECRETSFX, 0, 0 },
47204 {"MAPDATAHOLDUPSFX", MAPDATAHOLDUPSFX, 0, 0 },
47205 {"MAPDATASCREENMIDI", MAPDATASCREENMIDI, 0, 0 },
47206 {"MAPDATALENSLAYER", MAPDATALENSLAYER, 0, 0 },
47207 {"MAPDATAMISCD", MAPDATAMISCD, 0, 0},
47208
47209 {"MAPDATASCREENSTATED", MAPDATASCREENSTATED, 0, 0},
47210 {"MAPDATASCREENFLAGSD", MAPDATASCREENFLAGSD, 0, 0},
47211 {"MAPDATASCREENEFLAGSD", MAPDATASCREENEFLAGSD, 0, 0},
47212
47213
47214
47215 {"MAPDATACOMBODD", MAPDATACOMBODD, 0, 0},
47216 {"MAPDATACOMBOCD", MAPDATACOMBOCD, 0, 0},
47217 {"MAPDATACOMBOFD", MAPDATACOMBOFD, 0, 0},
47218 {"MAPDATACOMBOTD", MAPDATACOMBOTD, 0, 0},
47219 {"MAPDATACOMBOID", MAPDATACOMBOID, 0, 0},
47220 {"MAPDATACOMBOSD", MAPDATACOMBOSD, 0, 0},
47221
47222 {"SCREENDATAVALID", SCREENDATAVALID, 0, 0 },
47223 {"SCREENDATAGUY", SCREENDATAGUY, 0, 0 },
47224 {"SCREENDATASTRING", SCREENDATASTRING, 0, 0 },
47225 {"SCREENDATAROOM", SCREENDATAROOM, 0, 0 },
47226 {"SCREENDATAITEM", SCREENDATAITEM, 0, 0 },
47227 {"SCREENDATAHASITEM", SCREENDATAHASITEM, 0, 0 },
47228 {"SCREENDATATILEWARPTYPE", SCREENDATATILEWARPTYPE, 0, 0 },
47229 {"SCREENDATATILEWARPOVFLAGS", SCREENDATATILEWARPOVFLAGS, 0, 0 },
47230 {"SCREENDATADOORCOMBOSET", SCREENDATADOORCOMBOSET, 0, 0 },
47231 {"SCREENDATAWARPRETX", SCREENDATAWARPRETX, 0, 0 },
47232 {"SCREENDATAWARPRETY", SCREENDATAWARPRETY, 0, 0 },
47233 {"SCREENDATAWARPRETURNC", SCREENDATAWARPRETURNC, 0, 0 },
47234 {"SCREENDATASTAIRX", SCREENDATASTAIRX, 0, 0 },
47235 {"SCREENDATASTAIRY", SCREENDATASTAIRY, 0, 0 },
47236 {"SCREENDATACOLOUR", SCREENDATACOLOUR, 0, 0 },
47237 {"SCREENDATAENEMYFLAGS", SCREENDATAENEMYFLAGS, 0, 0 },
47238 {"SCREENDATADOOR", SCREENDATADOOR, 0, 0 },
47239 {"SCREENDATATILEWARPDMAP", SCREENDATATILEWARPDMAP, 0, 0 },
47240 {"SCREENDATATILEWARPSCREEN", SCREENDATATILEWARPSCREEN, 0, 0 },
47241 {"SCREENDATAEXITDIR", SCREENDATAEXITDIR, 0, 0 },
47242 {"SCREENDATAENEMY", SCREENDATAENEMY, 0, 0 },
47243 {"SCREENDATAPATTERN", SCREENDATAPATTERN, 0, 0 },
47244 {"SCREENDATASIDEWARPTYPE", SCREENDATASIDEWARPTYPE, 0, 0 },
47245 {"SCREENDATASIDEWARPOVFLAGS", SCREENDATASIDEWARPOVFLAGS, 0, 0 },
47246 {"SCREENDATAWARPARRIVALX", SCREENDATAWARPARRIVALX, 0, 0 },
47247 {"SCREENDATAWARPARRIVALY", SCREENDATAWARPARRIVALY, 0, 0 },
47248 {"SCREENDATAPATH", SCREENDATAPATH, 0, 0 },
47249 {"SCREENDATASIDEWARPSC", SCREENDATASIDEWARPSC, 0, 0 },
47250 {"SCREENDATASIDEWARPDMAP", SCREENDATASIDEWARPDMAP, 0, 0 },
47251 {"SCREENDATASIDEWARPINDEX", SCREENDATASIDEWARPINDEX, 0, 0 },
47252 {"SCREENDATAUNDERCOMBO", SCREENDATAUNDERCOMBO, 0, 0 },
47253 {"SCREENDATAUNDERCSET", SCREENDATAUNDERCSET, 0, 0 },
47254 {"SCREENDATACATCHALL", SCREENDATACATCHALL, 0, 0 },
47255 {"SCREENDATAFLAGS", SCREENDATAFLAGS, 0, 0 },
47256 {"SCREENDATACSENSITIVE", SCREENDATACSENSITIVE, 0, 0 },
47257 {"SCREENDATANORESET", SCREENDATANORESET, 0, 0 },
47258 {"SCREENDATANOCARRY", SCREENDATANOCARRY, 0, 0 },
47259 {"SCREENDATALAYERMAP", SCREENDATALAYERMAP, 0, 0 },
47260 {"SCREENDATALAYERSCREEN", SCREENDATALAYERSCREEN, 0, 0 },
47261 {"SCREENDATALAYEROPACITY", SCREENDATALAYEROPACITY, 0, 0 },
47262 {"SCREENDATATIMEDWARPTICS", SCREENDATATIMEDWARPTICS, 0, 0 },
47263 {"SCREENDATANEXTMAP", SCREENDATANEXTMAP, 0, 0 },
47264 {"SCREENDATANEXTSCREEN", SCREENDATANEXTSCREEN, 0, 0 },
47265 {"SCREENDATASECRETCOMBO", SCREENDATASECRETCOMBO, 0, 0 },
47266 {"SCREENDATASECRETCSET", SCREENDATASECRETCSET, 0, 0 },
47267 {"SCREENDATASECRETFLAG", SCREENDATASECRETFLAG, 0, 0 },
47268 {"SCREENDATAVIEWX", SCREENDATAVIEWX, 0, 0 },
47269 {"SCREENDATAVIEWY", SCREENDATAVIEWY, 0, 0 },
47270 {"SCREENDATASCREENWIDTH", SCREENDATASCREENWIDTH, 0, 0 },
47271 {"SCREENDATASCREENHEIGHT", SCREENDATASCREENHEIGHT, 0, 0 },
47272 {"SCREENDATAENTRYX", SCREENDATAENTRYX, 0, 0 },
47273 {"SCREENDATAENTRYY", SCREENDATAENTRYY, 0, 0 },
47274 {"SCREENDATANUMFF", SCREENDATANUMFF, 0, 0 },
47275 {"SCREENDATAFFDATA", SCREENDATAFFDATA, 0, 0 },
47276 {"SCREENDATAFFCSET", SCREENDATAFFCSET, 0, 0 },
47277 {"SCREENDATAFFDELAY", SCREENDATAFFDELAY, 0, 0 },
47278 {"SCREENDATAFFX", SCREENDATAFFX, 0, 0 },
47279 {"SCREENDATAFFY", SCREENDATAFFY, 0, 0 },
47280 {"SCREENDATAFFXDELTA", SCREENDATAFFXDELTA, 0, 0 },
47281 {"SCREENDATAFFYDELTA", SCREENDATAFFYDELTA, 0, 0 },
47282 {"SCREENDATAFFXDELTA2", SCREENDATAFFXDELTA2, 0, 0 },
47283 {"SCREENDATAFFYDELTA2", SCREENDATAFFYDELTA2, 0, 0 },
47284 {"SCREENDATAFFFLAGS", SCREENDATAFFFLAGS, 0, 0 },
47285 {"SCREENDATAFFWIDTH", SCREENDATAFFWIDTH, 0, 0 },
47286 {"SCREENDATAFFHEIGHT", SCREENDATAFFHEIGHT, 0, 0 },
47287 {"SCREENDATAFFLINK", SCREENDATAFFLINK, 0, 0 },
47288 {"SCREENDATAFFSCRIPT", SCREENDATAFFSCRIPT, 0, 0 },
47289 {"SCREENDATAINTID", SCREENDATAINTID, 0, 0 }, //Needs to be a function [32][10]
47290 {"SCREENDATAINITA", SCREENDATAINITA, 0, 0 }, //needs to be a function, [32][2]
47291 {"SCREENDATAFFINITIALISED", SCREENDATAFFINITIALISED, 0, 0 },
47292 {"SCREENDATASCRIPTENTRY", SCREENDATASCRIPTENTRY, 0, 0 },
47293 {"SCREENDATASCRIPTOCCUPANCY", SCREENDATASCRIPTOCCUPANCY, 0, 0 },
47294 {"SCREENDATASCRIPTEXIT", SCREENDATASCRIPTEXIT, 0, 0 },
47295 {"SCREENDATAOCEANSFX", SCREENDATAOCEANSFX, 0, 0 },
47296 {"SCREENDATABOSSSFX", SCREENDATABOSSSFX, 0, 0 },
47297 {"SCREENDATASECRETSFX", SCREENDATASECRETSFX, 0, 0 },
47298 {"SCREENDATAHOLDUPSFX", SCREENDATAHOLDUPSFX, 0, 0 },
47299 {"SCREENDATASCREENMIDI", SCREENDATASCREENMIDI, 0, 0 },
47300 {"SCREENDATALENSLAYER", SCREENDATALENSLAYER, 0, 0 },
47301
47302 {"LINKSCRIPTTILE", LINKSCRIPTTILE, 0, 0 },
47303 {"LINKSCRIPFLIP", LINKSCRIPFLIP, 0, 0 },
47304 {"MAPDATAITEMX", MAPDATAITEMX, 0, 0 },
47305 {"MAPDATAITEMY", MAPDATAITEMY, 0, 0 },
47306 {"SCREENDATAITEMX", SCREENDATAITEMX, 0, 0 },
47307 {"SCREENDATAITEMY", SCREENDATAITEMY, 0, 0 },
47308
47309 {"MAPDATAFFEFFECTWIDTH", MAPDATAFFEFFECTWIDTH, 0, 0 },
47310 {"MAPDATAFFEFFECTHEIGHT", MAPDATAFFEFFECTHEIGHT, 0, 0 },
47311 {"SCREENDATAFFEFFECTWIDTH", SCREENDATAFFEFFECTWIDTH, 0, 0 },
47312 {"SCREENDATAFFEFFECTHEIGHT", SCREENDATAFFEFFECTHEIGHT, 0, 0 },
47313
47314 {"LOADMAPDATA", LOADMAPDATA, 0, 0 },
47315 {"LWPNPARENT", LWPNPARENT, 0, 0 },
47316 {"LWPNLEVEL", LWPNLEVEL, 0, 0 },
47317 {"EWPNLEVEL", EWPNLEVEL, 0, 0 },
47318 {"EWPNPARENT", EWPNPARENT, 0, 0 },
47319
47320
47321 {"SHOPDATANAME", SHOPDATANAME, 0, 0 },
47322 {"SHOPDATAITEM", SHOPDATAITEM, 0, 0 },
47323 {"SHOPDATAHASITEM", SHOPDATAHASITEM, 0, 0 },
47324 {"SHOPDATAPRICE", SHOPDATAPRICE, 0, 0 },
47325 {"SHOPDATASTRING", SHOPDATASTRING, 0, 0 },
47326
47327 {"NPCDATASHIELD", NPCDATASHIELD, 0, 0 },
47328 {"NPCSHIELD", NPCSHIELD, 0, 0 },
47329 {"AUDIOVOLUME", AUDIOVOLUME, 0, 0 },
47330 {"AUDIOPAN", AUDIOPAN, 0, 0 },
47331
47332 {"MESSAGEDATANEXT", MESSAGEDATANEXT, 0, 0 },
47333 {"MESSAGEDATATILE", MESSAGEDATATILE, 0, 0 },
47334 {"MESSAGEDATACSET", MESSAGEDATACSET, 0, 0 },
47335 {"MESSAGEDATATRANS", MESSAGEDATATRANS, 0, 0 },
47336 {"MESSAGEDATAFONT", MESSAGEDATAFONT, 0, 0 },
47337 {"MESSAGEDATAX", MESSAGEDATAX, 0, 0 },
47338 {"MESSAGEDATAY", MESSAGEDATAY, 0, 0 },
47339 {"MESSAGEDATAW", MESSAGEDATAW, 0, 0 },
47340 {"MESSAGEDATAH", MESSAGEDATAH, 0, 0 },
47341 {"MESSAGEDATASFX", MESSAGEDATASFX, 0, 0 },
47342 {"MESSAGEDATALISTPOS", MESSAGEDATALISTPOS, 0, 0 },
47343 {"MESSAGEDATAVSPACE", MESSAGEDATAVSPACE, 0, 0 },
47344 {"MESSAGEDATAHSPACE", MESSAGEDATAHSPACE, 0, 0 },
47345 {"MESSAGEDATAFLAGS", MESSAGEDATAFLAGS, 0, 0 },
47346
47347 {"DMAPDATAMAP", DMAPDATAMAP, 0, 0 },
47348 {"DMAPDATALEVEL", DMAPDATALEVEL, 0, 0 },
47349 {"DMAPDATAOFFSET", DMAPDATAOFFSET, 0, 0 },
47350 {"DMAPDATACOMPASS", DMAPDATACOMPASS, 0, 0 },
47351 {"DMAPDATAPALETTE", DMAPDATAPALETTE, 0, 0 },
47352 {"DMAPDATAMIDI", DMAPDATAMIDI, 0, 0 },
47353 {"DMAPDATACONTINUE", DMAPDATACONTINUE, 0, 0 },
47354 {"DMAPDATATYPE", DMAPDATATYPE, 0, 0 },
47355 {"DMAPDATAGRID", DMAPDATAGRID, 0, 0 },
47356 {"DMAPDATAMINIMAPTILE", DMAPDATAMINIMAPTILE, 0, 0 },
47357 {"DMAPDATAMINIMAPCSET", DMAPDATAMINIMAPCSET, 0, 0 },
47358 {"DMAPDATALARGEMAPTILE", DMAPDATALARGEMAPTILE, 0, 0 },
47359 {"DMAPDATALARGEMAPCSET", DMAPDATALARGEMAPCSET, 0, 0 },
47360 {"DMAPDATAMUISCTRACK", DMAPDATAMUISCTRACK, 0, 0 },
47361 {"DMAPDATASUBSCRA", DMAPDATASUBSCRA, 0, 0 },
47362 {"DMAPDATASUBSCRP", DMAPDATASUBSCRP, 0, 0 },
47363 {"DMAPDATADISABLEDITEMS", DMAPDATADISABLEDITEMS, 0, 0 },
47364 {"DMAPDATAFLAGS", DMAPDATAFLAGS, 0, 0 },
47365
47366 {"NPCFROZEN", NPCFROZEN, 0, 0 },
47367 {"NPCFROZENTILE", NPCFROZENTILE, 0, 0 },
47368 {"NPCFROZENCSET", NPCFROZENCSET, 0, 0 },
47369
47370 {"ITEMPSTRING", ITEMPSTRING, 0, 0 },
47371 {"ITEMPSTRINGFLAGS", ITEMPSTRINGFLAGS, 0, 0 },
47372 {"ITEMOVERRIDEFLAGS", ITEMOVERRIDEFLAGS, 0, 0 },
47373 {"LINKPUSH", LINKPUSH, 0, 0 },
47374 {"LINKSTUN", LINKSTUN, 0, 0 },
47375 {"IDATACOSTCOUNTER", IDATACOSTCOUNTER, 0, 0 },
47376 {"TYPINGMODE", TYPINGMODE, 0, 0 },
47377 // {"DMAPDATAGRAVITY", DMAPDATAGRAVITY, 0, 0 },
47378 // {"DMAPDATAJUMPLAYER", DMAPDATAJUMPLAYER, 0, 0 },
47379 //end ffscript vars
47380 //END VARS END OF BYTECODE
47381
47382 //newcombo
47383 {"COMBODTILE", COMBODTILE, 0, 0 },
47384 {"COMBODFLIP", COMBODFLIP, 0, 0 },
47385 {"COMBODWALK", COMBODWALK, 0, 0 },
47386 {"COMBODTYPE", COMBODTYPE, 0, 0 },
47387 {"COMBODCSET", COMBODCSET, 0, 0 },
47388 {"COMBODFOO", COMBODFOO, 0, 0 },
47389 {"COMBODFRAMES", COMBODFRAMES, 0, 0 },
47390 {"COMBODNEXTD", COMBODNEXTD, 0, 0 },
47391 {"COMBODNEXTC", COMBODNEXTC, 0, 0 },
47392 {"COMBODFLAG", COMBODFLAG, 0, 0 },
47393 {"COMBODSKIPANIM", COMBODSKIPANIM, 0, 0 },
47394 {"COMBODNEXTTIMER", COMBODNEXTTIMER, 0, 0 },
47395 {"COMBODAKIMANIMY", COMBODAKIMANIMY, 0, 0 },
47396 {"COMBODANIMFLAGS", COMBODANIMFLAGS, 0, 0 },
47397 {"COMBODEXPANSION", COMBODEXPANSION, 0, 0 },
47398 {"COMBODATTRIBUTES", COMBODATTRIBUTES, 0, 0 },
47399 {"COMBODATTRIBYTES", COMBODATTRIBYTES, 0, 0 },
47400 {"COMBODUSRFLAGS", COMBODUSRFLAGS, 0, 0 },
47401 {"COMBODTRIGGERFLAGS", COMBODTRIGGERFLAGS, 0, 0 },
47402 {"COMBODTRIGGERLEVEL", COMBODTRIGGERLEVEL, 0, 0 },
47403
47404 //comboclass
47405 {"COMBODNAME", COMBODNAME, 0, 0 },
47406 {"COMBODBLOCKNPC", COMBODBLOCKNPC, 0, 0 },
47407 {"COMBODBLOCKHOLE", COMBODBLOCKHOLE, 0, 0 },
47408 {"COMBODBLOCKTRIG", COMBODBLOCKTRIG, 0, 0 },
47409 {"COMBODBLOCKWEAPON", COMBODBLOCKWEAPON, 0, 0 },
47410 {"COMBODCONVXSPEED", COMBODCONVXSPEED, 0, 0 },
47411 {"COMBODCONVYSPEED", COMBODCONVYSPEED, 0, 0 },
47412 {"COMBODSPAWNNPC", COMBODSPAWNNPC, 0, 0 },
47413 {"COMBODSPAWNNPCWHEN", COMBODSPAWNNPCWHEN, 0, 0 },
47414 {"COMBODSPAWNNPCCHANGE", COMBODSPAWNNPCCHANGE, 0, 0 },
47415 {"COMBODDIRCHANGETYPE", COMBODDIRCHANGETYPE, 0, 0 },
47416 {"COMBODDISTANCECHANGETILES", COMBODDISTANCECHANGETILES, 0, 0 },
47417 {"COMBODDIVEITEM", COMBODDIVEITEM, 0, 0 },
47418 {"COMBODDOCK", COMBODDOCK, 0, 0 },
47419 {"COMBODFAIRY", COMBODFAIRY, 0, 0 },
47420 {"COMBODFFATTRCHANGE", COMBODFFATTRCHANGE, 0, 0 },
47421 {"COMBODFOORDECOTILE", COMBODFOORDECOTILE, 0, 0 },
47422 {"COMBODFOORDECOTYPE", COMBODFOORDECOTYPE, 0, 0 },
47423 {"COMBODHOOKSHOTPOINT", COMBODHOOKSHOTPOINT, 0, 0 },
47424 {"COMBODLADDERPASS", COMBODLADDERPASS, 0, 0 },
47425 {"COMBODLOCKBLOCK", COMBODLOCKBLOCK, 0, 0 },
47426 {"COMBODLOCKBLOCKCHANGE", COMBODLOCKBLOCKCHANGE, 0, 0 },
47427 {"COMBODMAGICMIRROR", COMBODMAGICMIRROR, 0, 0 },
47428 {"COMBODMODHPAMOUNT", COMBODMODHPAMOUNT, 0, 0 },
47429 {"COMBODMODHPDELAY", COMBODMODHPDELAY, 0, 0 },
47430 {"COMBODMODHPTYPE", COMBODMODHPTYPE, 0, 0 },
47431 {"COMBODNMODMPAMOUNT", COMBODNMODMPAMOUNT, 0, 0 },
47432 {"COMBODMODMPDELAY", COMBODMODMPDELAY, 0, 0 },
47433 {"COMBODMODMPTYPE", COMBODMODMPTYPE, 0, 0 },
47434 {"COMBODNOPUSHBLOCK", COMBODNOPUSHBLOCK, 0, 0 },
47435 {"COMBODOVERHEAD", COMBODOVERHEAD, 0, 0 },
47436 {"COMBODPLACENPC", COMBODPLACENPC, 0, 0 },
47437 {"COMBODPUSHDIR", COMBODPUSHDIR, 0, 0 },
47438 {"COMBODPUSHWAIT", COMBODPUSHWAIT, 0, 0 },
47439 {"COMBODPUSHHEAVY", COMBODPUSHHEAVY, 0, 0 },
47440 {"COMBODPUSHED", COMBODPUSHED, 0, 0 },
47441 {"COMBODRAFT", COMBODRAFT, 0, 0 },
47442 {"COMBODRESETROOM", COMBODRESETROOM, 0, 0 },
47443 {"COMBODSAVEPOINTTYPE", COMBODSAVEPOINTTYPE, 0, 0 },
47444 {"COMBODSCREENFREEZETYPE", COMBODSCREENFREEZETYPE, 0, 0 },
47445 {"COMBODSECRETCOMBO", COMBODSECRETCOMBO, 0, 0 },
47446 {"COMBODSINGULAR", COMBODSINGULAR, 0, 0 },
47447 {"COMBODSLOWWALK", COMBODSLOWWALK, 0, 0 },
47448 {"COMBODSTATUETYPEs", COMBODSTATUETYPE, 0, 0 },
47449 {"COMBODSTEPTYPE", COMBODSTEPTYPE, 0, 0 },
47450 {"COMBODSTEPCHANGEINTO", COMBODSTEPCHANGEINTO, 0, 0 },
47451 {"COMBODSTRIKEWEAPONS", COMBODSTRIKEWEAPONS, 0, 0 },
47452 {"COMBODSTRIKEREMNANTS", COMBODSTRIKEREMNANTS, 0, 0 },
47453 {"COMBODSTRIKEREMNANTSTYPE", COMBODSTRIKEREMNANTSTYPE, 0, 0 },
47454 {"COMBODSTRIKECHANGE", COMBODSTRIKECHANGE, 0, 0 },
47455 {"COMBODSTRIKEITEM", COMBODSTRIKEITEM, 0, 0 },
47456 {"COMBODTOUCHITEM", COMBODTOUCHITEM, 0, 0 },
47457 {"COMBODTOUCHSTAIRS", COMBODTOUCHSTAIRS, 0, 0 },
47458 {"COMBODTRIGGERTYPE", COMBODTRIGGERTYPE, 0, 0 },
47459 {"COMBODTRIGGERSENS", COMBODTRIGGERSENS, 0, 0 },
47460 {"COMBODWARPTYPE", COMBODWARPTYPE, 0, 0 },
47461 {"COMBODWARPSENS", COMBODWARPSENS, 0, 0 },
47462 {"COMBODWARPDIRECT", COMBODWARPDIRECT, 0, 0 },
47463 {"COMBODWARPLOCATION", COMBODWARPLOCATION, 0, 0 },
47464 {"COMBODWATER", COMBODWATER, 0, 0 },
47465 {"COMBODWHISTLE", COMBODWHISTLE, 0, 0 },
47466 {"COMBODWINGAME", COMBODWINGAME, 0, 0 },
47467 {"COMBODBLOCKWPNLEVEL", COMBODBLOCKWPNLEVEL, 0, 0 },
47468
47469 {"TYPINGMODE", TYPINGMODE, 0, 0 },
47470 {"TYPINGMODE", TYPINGMODE, 0, 0 },
47471 {"LINKHITBY", LINKHITBY, 0, 0 },
47472 {"LINKDEFENCE", LINKDEFENCE, 0, 0 },
47473 {"NPCHITBY", NPCHITBY, 0, 0 },
47474 {"NPCISCORE", NPCISCORE, 0, 0 },
47475 {"NPCSCRIPTUID", NPCSCRIPTUID, 0, 0 },
47476 {"LWEAPONSCRIPTUID", LWEAPONSCRIPTUID, 0, 0 },
47477 {"EWEAPONSCRIPTUID", EWEAPONSCRIPTUID, 0, 0 },
47478 {"ITEMSCRIPTUID", ITEMSCRIPTUID, 0, 0 },
47479
47480 {"DMAPDATASIDEVIEW", DMAPDATASIDEVIEW, 0, 0 },
47481
47482 {"DONULL", DONULL, 0, 0 },
47483 {"DEBUGD", DEBUGD, 0, 0 },
47484 {"GETPIXEL", GETPIXEL, 0, 0 },
47485 {"DOUNTYPE", DOUNTYPE, 0, 0 },
47486 {"NPCBEHAVIOUR", NPCBEHAVIOUR, 0, 0 },
47487 {"NPCDATABEHAVIOUR", NPCDATABEHAVIOUR, 0, 0 },
47488 {"CREATEBITMAP", CREATEBITMAP, 0, 0 },
47489 {"LINKTILEMOD", LINKTILEMOD, 0, 0 },
47490 {"NPCINITD", NPCINITD, 0, 0 },
47491 {"NPCCOLLISION", NPCCOLLISION, 0, 0 },
47492 {"NPCLINEDUP", NPCLINEDUP, 0, 0 },
47493
47494 {"NPCDATAINITD", NPCLINEDUP, 0, 0 },
47495 {"NPCDATASCRIPT", NPCDATASCRIPT, 0, 0 },
47496 {"NPCMATCHINITDLABEL", NPCMATCHINITDLABEL, 0, 0 },
47497 //lweapon scripts
47498 {"LWPNSCRIPT", LWPNSCRIPT, 0, 0 },
47499 {"LWPNINITD", LWPNINITD, 0, 0 },
47500 {"ITEMFAMILY", ITEMFAMILY, 0, 0 },
47501 {"ITEMLEVEL", ITEMLEVEL, 0, 0 },
47502
47503 {"EWPNSCRIPT", EWPNSCRIPT, 0, 0 },
47504 {"EWPNINITD", EWPNINITD, 0, 0 },
47505
47506 {"NPCSCRIPT", NPCSCRIPT, 0, 0 },
47507
47508 {"DMAPSCRIPT", DMAPSCRIPT, 0, 0 },
47509 {"DMAPINITD", DMAPINITD, 0, 0 },
47510
47511 {"SCREENSCRIPT", SCREENSCRIPT, 0, 0 },
47512 {"SCREENINITD", SCREENINITD, 0, 0 },
47513
47514 {"LINKINITD", LINKINITD, 0, 0 },
47515 {"NPCDATAWEAPONINITD", NPCDATAWEAPONINITD, 0, 0 },
47516 {"NPCDATAWEAPONSCRIPT", NPCDATAWEAPONSCRIPT, 0, 0 },
47517
47518 {"NPCSCRIPTTILE", NPCSCRIPTTILE, 0, 0 },
47519 {"NPCSCRIPTFLIP", NPCSCRIPTFLIP, 0, 0 },
47520 {"LWPNSCRIPTTILE", LWPNSCRIPTTILE, 0, 0 },
47521 {"LWPNSCRIPTFLIP", LWPNSCRIPTFLIP, 0, 0 },
47522 {"EWPNSCRIPTTILE", EWPNSCRIPTTILE, 0, 0 },
47523 {"EWPNSCRIPTFLIP", EWPNSCRIPTFLIP, 0, 0 },
47524
47525 {"LINKENGINEANIMATE", LINKENGINEANIMATE, 0, 0 },
47526 {"NPCENGINEANIMATE", NPCENGINEANIMATE, 0, 0 },
47527 {"LWPNENGINEANIMATE", LWPNENGINEANIMATE, 0, 0 },
47528 {"EWPNENGINEANIMATE", EWPNENGINEANIMATE, 0, 0 },
47529 {"SKIPCREDITS", SKIPCREDITS, 0, 0 },
47530 {"SKIPF6", SKIPF6, 0, 0 },
47531 {"LWPNUSEWEAPON", LWPNUSEWEAPON, 0, 0 },
47532 {"LWPNUSEDEFENCE", LWPNUSEDEFENCE, 0, 0 },
47533 {"LWPNROTATION", LWPNROTATION, 0, 0 },
47534 {"EWPNROTATION", EWPNROTATION, 0, 0 },
47535 {"NPCROTATION", NPCROTATION, 0, 0 },
47536 {"ITEMROTATION", ITEMROTATION, 0, 0 },
47537 {"LINKROTATION", LINKROTATION, 0, 0 },
47538 {"LWPNSCALE", LWPNSCALE, 0, 0 },
47539 {"EWPNSCALE", EWPNSCALE, 0, 0 },
47540 {"NPCSCALE", NPCSCALE, 0, 0 },
47541 {"ITEMSCALE", ITEMSCALE, 0, 0 },
47542 {"LINKSCALE", LINKSCALE, 0, 0 },
47543 {"ITEMSPRITESCRIPT", ITEMSPRITESCRIPT, 0, 0 },
47544 {"FFRULE", FFRULE, 0, 0 },
47545 {"NUMDRAWS", NUMDRAWS, 0, 0 },
47546 {"MAXDRAWS", MAXDRAWS, 0, 0 },
47547 {"BITMAPWIDTH", BITMAPWIDTH, 0, 0 },
47548 {"BITMAPHEIGHT", BITMAPHEIGHT, 0, 0 },
47549 {"ALLOCATEBITMAPR", ALLOCATEBITMAPR, 0, 0 },
47550 {"KEYMODIFIERS", KEYMODIFIERS, 0, 0 },
47551 {"SIMULATEKEYPRESS", SIMULATEKEYPRESS, 0, 0 },
47552 {"KEYBINDINGS", KEYBINDINGS, 0, 0 },
47553
47554 {"SCREENSCRIPT", SCREENSCRIPT, 0, 0 },
47555 {"SCREENINITD", SCREENINITD, 0, 0 },
47556 {"MAPDATASCRIPT", MAPDATASCRIPT, 0, 0 },
47557 {"MAPDATAINITDARRAY", MAPDATAINITDARRAY, 0, 0 },
47558 {"LWPNGRAVITY", LWPNGRAVITY, 0, 0 },
47559 {"EWPNGRAVITY", EWPNGRAVITY, 0, 0 },
47560 {"NPCGRAVITY", NPCGRAVITY, 0, 0 },
47561 {"ITEMGRAVITY", ITEMGRAVITY, 0, 0 },
47562
47563 {"MAPDATASIDEWARPID", MAPDATASIDEWARPID, 0, 0 },
47564 {"SCREENSIDEWARPID", SCREENSIDEWARPID, 0, 0 },
47565 {"SCREENDATALAYERINVIS", SCREENDATALAYERINVIS, 0, 0 },
47566 {"SCREENDATASCRIPTDRAWS", SCREENDATASCRIPTDRAWS, 0, 0 },
47567 {"MAPDATALAYERINVIS", MAPDATALAYERINVIS, 0, 0 },
47568 {"MAPDATASCRIPTDRAWS", MAPDATASCRIPTDRAWS, 0, 0 },
47569
47570 {"ITEMSCRIPTTILE", ITEMSCRIPTTILE, 0, 0 },
47571 {"ITEMSCRIPTFLIP", ITEMSCRIPTFLIP, 0, 0 },
47572 {"MAPDATAMAP", MAPDATAMAP, 0, 0 },
47573 {"MAPDATASCREEN", MAPDATASCREEN, 0, 0 },
47574 {"IDATAVALIDATE", IDATAVALIDATE, 0, 0 },
47575 { "DISABLEKEY", DISABLEKEY, 0, 0 },
47576 { "DISABLEBUTTON", DISABLEBUTTON, 0, 0 },
47577 { "GAMESUSPEND", GAMESUSPEND, 0, 0 },
47578 { "LINKOTILE", LINKOTILE, 0, 0 },
47579 { "LINKOFLIP", LINKOFLIP, 0, 0 },
47580 { "ITEMSPRITEINITD", ITEMSPRITEINITD, 0, 0 },
47581
47582 { "ZSCRIPTVERSION", ZSCRIPTVERSION, 0, 0 },
47583 { "REFFILE", REFFILE, 0, 0 },
47584 { "LINKCLIMBING", LINKCLIMBING, 0, 0 },
47585 { "NPCIMMORTAL", NPCIMMORTAL, 0, 0 },
47586 { "NPCNOSLIDE", NPCNOSLIDE, 0, 0 },
47587 { "NPCKNOCKBACKSPEED", NPCKNOCKBACKSPEED, 0, 0 },
47588 { "NPCNOSCRIPTKB", NPCNOSCRIPTKB, 0, 0 },
47589 { "GETRENDERTARGET", GETRENDERTARGET, 0, 0 },
47590 { "HERONOSTEPFORWARD", HERONOSTEPFORWARD, 0, 0 },
47591 { "SCREENDATATWARPRETSQR", SCREENDATATWARPRETSQR, 0, 0 },
47592 { "SCREENDATASWARPRETSQR", SCREENDATASWARPRETSQR, 0, 0 },
47593 { "MAPDATATWARPRETSQR", MAPDATATWARPRETSQR, 0, 0 },
47594 { "MAPDATASWARPRETSQR", MAPDATASWARPRETSQR, 0, 0 },
47595 { "NPCSUBMERGED", NPCSUBMERGED, 0, 0 },
47596 { "GAMEGRAVITY", GAMEGRAVITY, 0, 0 },
47597 { "COMBODASPEED", COMBODASPEED, 0, 0 },
47598 { "DROPSETITEMS", DROPSETITEMS, 0, 0 },
47599 { "DROPSETCHANCES", DROPSETCHANCES, 0, 0 },
47600 { "DROPSETNULLCHANCE", DROPSETNULLCHANCE, 0, 0 },
47601 { "DROPSETCHOOSE", DROPSETCHOOSE, 0, 0 },
47602 { "NPCPARENTUID", NPCPARENTUID, 0, 0 },
47603 { "KEYPRESS", KEYPRESS, 0, 0 },
47604 { "KEYINPUT", KEYINPUT, 0, 0 },
47605 { "SPRITEMAXNPC", SPRITEMAXNPC, 0, 0 },
47606 { "SPRITEMAXLWPN", SPRITEMAXLWPN, 0, 0 },
47607 { "SPRITEMAXEWPN", SPRITEMAXEWPN, 0, 0 },
47608 { "SPRITEMAXITEM", SPRITEMAXITEM, 0, 0 },
47609 { "SPRITEMAXPARTICLE", SPRITEMAXPARTICLE, 0, 0 },
47610 { "SPRITEMAXDECO", SPRITEMAXDECO, 0, 0 },
47611 { "HEROHEALTHBEEP", HEROHEALTHBEEP, 0, 0 },
47612 { "NPCRANDOM", NPCRANDOM, 0, 0 },
47613 { "COMBOXR", COMBOXR, 0, 0 },
47614 { "COMBOYR", COMBOYR, 0, 0 },
47615 { "COMBOPOSR", COMBOPOSR, 0, 0 },
47616 { "COMBODATASCRIPT", COMBODATASCRIPT, 0, 0 },
47617 { "COMBODATAINITD", COMBODATAINITD, 0, 0 },
47618 { "HEROSCRIPTCSET", HEROSCRIPTCSET, 0, 0 },
47619 { "SHOPDATATYPE", SHOPDATATYPE, 0, 0 },
47620 { "HEROSTEPS", HEROSTEPS, 0, 0 },
47621 { "HEROSTEPRATE", HEROSTEPRATE, 0, 0 },
47622 { "COMBODOTILE", COMBODOTILE, 0, 0 },
47623 { "COMBODFRAME", COMBODFRAME, 0, 0 },
47624 { "COMBODACLK", COMBODACLK, 0, 0 },
47625 { "PC", PC, 0, 0 },
47626 { "GAMESCROLLING", GAMESCROLLING, 0, 0 },
47627 { "MESSAGEDATAMARGINS", MESSAGEDATAMARGINS, 0, 0 },
47628 { "MESSAGEDATAPORTTILE", MESSAGEDATAPORTTILE, 0, 0 },
47629 { "MESSAGEDATAPORTCSET", MESSAGEDATAPORTCSET, 0, 0 },
47630 { "MESSAGEDATAPORTX", MESSAGEDATAPORTX, 0, 0 },
47631 { "MESSAGEDATAPORTY", MESSAGEDATAPORTY, 0, 0 },
47632 { "MESSAGEDATAPORTWID", MESSAGEDATAPORTWID, 0, 0 },
47633 { "MESSAGEDATAPORTHEI", MESSAGEDATAPORTHEI, 0, 0 },
47634 { "MESSAGEDATAFLAGSARR", MESSAGEDATAFLAGSARR, 0, 0 },
47635 { "FILEPOS", FILEPOS, 0, 0 },
47636 { "FILEEOF", FILEEOF, 0, 0 },
47637 { "FILEERR", FILEERR, 0, 0 },
47638 { "MESSAGEDATATEXTWID", MESSAGEDATATEXTWID, 0, 0 },
47639 { "MESSAGEDATATEXTHEI", MESSAGEDATATEXTHEI, 0, 0 },
47640 { "SWITCHKEY", SWITCHKEY, 0, 0 },
47641 { "INCQST", INCQST, 0, 0 },
47642 { "HEROJUMPCOUNT", HEROJUMPCOUNT, 0, 0 },
47643 { "HEROPULLDIR", HEROPULLDIR, 0, 0 },
47644 { "HEROPULLCLK", HEROPULLCLK, 0, 0 },
47645 { "HEROFALLCLK", HEROFALLCLK, 0, 0 },
47646 { "HEROFALLCMB", HEROFALLCMB, 0, 0 },
47647 { "HEROMOVEFLAGS", HEROMOVEFLAGS, 0, 0 },
47648 { "ITEMFALLCLK", ITEMFALLCLK, 0, 0 },
47649 { "ITEMFALLCMB", ITEMFALLCMB, 0, 0 },
47650 { "ITEMMOVEFLAGS", ITEMMOVEFLAGS, 0, 0 },
47651 { "LWPNFALLCLK", LWPNFALLCLK, 0, 0 },
47652 { "LWPNFALLCMB", LWPNFALLCMB, 0, 0 },
47653 { "LWPNMOVEFLAGS", LWPNMOVEFLAGS, 0, 0 },
47654 { "EWPNFALLCLK", EWPNFALLCLK, 0, 0 },
47655 { "EWPNFALLCMB", EWPNFALLCMB, 0, 0 },
47656 { "EWPNMOVEFLAGS", EWPNMOVEFLAGS, 0, 0 },
47657 { "NPCFALLCLK", NPCFALLCLK, 0, 0 },
47658 { "NPCFALLCMB", NPCFALLCMB, 0, 0 },
47659 { "NPCMOVEFLAGS", NPCMOVEFLAGS, 0, 0 },
47660 { "ISBLANKTILE", ISBLANKTILE, 0, 0 },
47661 { "LWPNSPECIAL", LWPNSPECIAL, 0, 0 },
47662 { "DMAPDATAASUBSCRIPT", DMAPDATAASUBSCRIPT, 0, 0 },
47663 { "DMAPDATAPSUBSCRIPT", DMAPDATAPSUBSCRIPT, 0, 0 },
47664 { "DMAPDATASUBINITD", DMAPDATASUBINITD, 0, 0 },
47665 { "MODULEGETINT", MODULEGETINT, 0, 0 },
47666 { "MODULEGETSTR", MODULEGETSTR, 0, 0 },
47667 { "NPCORIGINALHP", NPCORIGINALHP, 0, 0 },
47668 { "DMAPDATAMAPSCRIPT", DMAPDATAMAPSCRIPT, 0, 0 },
47669 { "DMAPDATAMAPINITD", DMAPDATAMAPINITD, 0, 0 },
47670 { "CLOCKCLK", CLOCKCLK, 0, 0 },
47671 { "CLOCKACTIVE", CLOCKACTIVE, 0, 0 },
47672 { "NPCHITDIR", NPCHITDIR, 0, 0 },
47673 { "DMAPDATAFLAGARR", DMAPDATAFLAGARR, 0, 0 },
47674 { "LINKCSET", LINKCSET, 0, 0 },
47675 { "NPCSLIDECLK", NPCSLIDECLK, 0, 0 },
47676 { "NPCFADING", NPCFADING, 0, 0 },
47677 { "DISTANCE", DISTANCE, 0, 0 },
47678 { "STDARR", STDARR, 0, 0 },
47679 { "GHOSTARR", GHOSTARR, 0, 0 },
47680 { "TANGOARR", TANGOARR, 0, 0 },
47681 { "NPCHALTCLK", NPCHALTCLK, 0, 0 },
47682 { "NPCMOVESTATUS", NPCMOVESTATUS, 0, 0 },
47683 { "DISTANCESCALE", DISTANCESCALE, 0, 0 },
47684 { "DMAPDATACHARTED", DMAPDATACHARTED, 0, 0 },
47685 { "REFDIRECTORY", REFDIRECTORY, 0, 0 },
47686 { "DIRECTORYSIZE", DIRECTORYSIZE, 0, 0 },
47687 { "LONGDISTANCE", LONGDISTANCE, 0, 0 },
47688 { "LONGDISTANCESCALE", LONGDISTANCESCALE, 0, 0 },
47689 { "COMBOED", COMBOED, 0, 0 },
47690 { "MAPDATACOMBOED", MAPDATACOMBOED, 0, 0 },
47691 { "COMBODEFFECT", COMBODEFFECT, 0, 0 },
47692 { "SCREENSECRETSTRIGGERED", SCREENSECRETSTRIGGERED, 0, 0 },
47693 { "ITEMDIR", ITEMDIR, 0, 0 },
47694 { "NPCFRAME", NPCFRAME, 0, 0 },
47695 { "LINKITEMX", LINKITEMX, 0, 0 },
47696 { "LINKITEMY", LINKITEMY, 0, 0 },
47697 { "ACTIVESSSPEED", ACTIVESSSPEED, 0, 0 },
47698 { "HEROISWARPING", HEROISWARPING, 0, 0 },
47699 { "ITEMGLOWRAD", ITEMGLOWRAD, 0, 0 },
47700 { "NPCGLOWRAD", NPCGLOWRAD, 0, 0 },
47701 { "LWPNGLOWRAD", LWPNGLOWRAD, 0, 0 },
47702 { "EWPNGLOWRAD", EWPNGLOWRAD, 0, 0 },
47703 { "ITEMGLOWSHP", ITEMGLOWSHP, 0, 0 },
47704 { "NPCGLOWSHP", NPCGLOWSHP, 0, 0 },
47705 { "LWPNGLOWSHP", LWPNGLOWSHP, 0, 0 },
47706 { "EWPNGLOWSHP", EWPNGLOWSHP, 0, 0 },
47707 { "ITEMENGINEANIMATE", ITEMENGINEANIMATE, 0, 0 },
47708 { "REFRNG", REFRNG, 0, 0 },
47709 { "LWPNUNBL", LWPNUNBL, 0, 0 },
47710 { "EWPNUNBL", EWPNUNBL, 0, 0 },
47711 { "NPCSHADOWSPR", NPCSHADOWSPR, 0, 0 },
47712 { "LWPNSHADOWSPR", LWPNSHADOWSPR, 0, 0 },
47713 { "EWPNSHADOWSPR", EWPNSHADOWSPR, 0, 0 },
47714 { "ITEMSHADOWSPR", ITEMSHADOWSPR, 0, 0 },
47715 { "NPCSPAWNSPR", NPCSPAWNSPR, 0, 0 },
47716 { "NPCDEATHSPR", NPCDEATHSPR, 0, 0 },
47717 { "NPCDSHADOWSPR", NPCDSHADOWSPR, 0, 0 },
47718 { "NPCDSPAWNSPR", NPCDSPAWNSPR, 0, 0 },
47719 { "NPCDDEATHSPR", NPCDDEATHSPR, 0, 0 },
47720
47721 { "COMBOLAYERR", COMBOLAYERR, 0, 0 },
47722 { "COMBODATTRISHORTS", COMBODATTRISHORTS, 0, 0 },
47723
47724 { "PUSHBLOCKLAYER", PUSHBLOCKLAYER, 0, 0 },
47725 { "LINKGRABBED", LINKGRABBED, 0, 0 },
47726 { "HEROBUNNY", HEROBUNNY, 0, 0 },
47727
47728 { "GAMELSWITCH", GAMELSWITCH, 0, 0 },
47729 { "GAMEBOTTLEST", GAMEBOTTLEST, 0, 0 },
47730
47731 { "REFBOTTLETYPE", REFBOTTLETYPE, 0, 0 },
47732 { "REFBOTTLESHOP", REFBOTTLESHOP, 0, 0 },
47733 { "BOTTLECOUNTER", BOTTLECOUNTER, 0, 0 },
47734 { "BOTTLEAMOUNT", BOTTLEAMOUNT, 0, 0 },
47735 { "BOTTLEPERCENT", BOTTLEPERCENT, 0, 0 },
47736 { "BOTTLEFLAGS", BOTTLEFLAGS, 0, 0 },
47737 { "BOTTLENEXT", BOTTLENEXT, 0, 0 },
47738 { "BSHOPFILL", BSHOPFILL, 0, 0 },
47739 { "BSHOPCOMBO", BSHOPCOMBO, 0, 0 },
47740 { "BSHOPCSET", BSHOPCSET, 0, 0 },
47741 { "BSHOPPRICE", BSHOPPRICE, 0, 0 },
47742 { "BSHOPSTR", BSHOPSTR, 0, 0 },
47743 { "COMBODUSRFLAGARR", COMBODUSRFLAGARR, 0, 0 },
47744 { "COMBODGENFLAGARR", COMBODGENFLAGARR, 0, 0 },
47745 { "HERORESPAWNX", HERORESPAWNX, 0, 0 },
47746 { "HERORESPAWNY", HERORESPAWNY, 0, 0 },
47747 { "HERORESPAWNDMAP", HERORESPAWNDMAP, 0, 0 },
47748 { "HERORESPAWNSCR", HERORESPAWNSCR, 0, 0 },
47749 { "IDATAUSESOUND2", IDATAUSESOUND2, 0, 0 },
47750 { "HEROSWITCHTIMER", HEROSWITCHTIMER, 0, 0 },
47751 { "HEROSWITCHMAXTIMER", HEROSWITCHMAXTIMER, 0, 0 },
47752 { "NPCSWHOOKED", NPCSWHOOKED, 0, 0 },
47753 { "GAMEMISCSPR", GAMEMISCSPR, 0, 0 },
47754 { "GAMEMISCSFX", GAMEMISCSFX, 0, 0 },
47755 { "HEROTOTALDYOFFS", HEROTOTALDYOFFS, 0, 0 },
47756 { "NPCTOTALDYOFFS", NPCTOTALDYOFFS, 0, 0 },
47757 { "LWPNTOTALDYOFFS", LWPNTOTALDYOFFS, 0, 0 },
47758 { "EWPNTOTALDYOFFS", EWPNTOTALDYOFFS, 0, 0 },
47759 { "LWSWHOOKED", LWSWHOOKED, 0, 0 },
47760 { "EWSWHOOKED", EWSWHOOKED, 0, 0 },
47761 { "ITMSWHOOKED", ITMSWHOOKED, 0, 0 },
47762 { "DEBUGTESTING", DEBUGTESTING, 0, 0 },
47763 { "GAMEMAXCHEAT", GAMEMAXCHEAT, 0, 0 },
47764 { "SHOWNMSG", SHOWNMSG, 0, 0 },
47765 { "COMBODTRIGGERBUTTON", COMBODTRIGGERBUTTON, 0, 0 },
47766 { "REFGENERICDATA", REFGENERICDATA, 0, 0 },
47767 { "GENDATARUNNING", GENDATARUNNING, 0, 0 },
47768 { "GENDATASIZE", GENDATASIZE, 0, 0 },
47769 { "GENDATAEXITSTATE", GENDATAEXITSTATE, 0, 0 },
47770 { "GENDATADATA", GENDATADATA, 0, 0 },
47771 { "GENDATAINITD", GENDATAINITD, 0, 0 },
47772 { "GENDATARELOADSTATE", GENDATARELOADSTATE, 0, 0 },
47773 { "COMBODCSET2FLAGS", COMBODCSET2FLAGS, 0, 0 },
47774 { "HEROIMMORTAL", HEROIMMORTAL, 0, 0 },
47775 { "NPCCANFLICKER", NPCCANFLICKER, 0, 0 },
47776 { "NPCDROWNCLK", NPCDROWNCLK, 0, 0 },
47777 { "NPCDROWNCMB", NPCDROWNCMB, 0, 0 },
47778 { "ITEMDROWNCLK", ITEMDROWNCLK, 0, 0 },
47779 { "ITEMDROWNCMB", ITEMDROWNCMB, 0, 0 },
47780 { "LWPNDROWNCLK", LWPNDROWNCLK, 0, 0 },
47781 { "LWPNDROWNCMB", LWPNDROWNCMB, 0, 0 },
47782 { "EWPNDROWNCLK", EWPNDROWNCLK, 0, 0 },
47783 { "EWPNDROWNCMB", EWPNDROWNCMB, 0, 0 },
47784 { "HERODROWNCLK", HERODROWNCLK, 0, 0 },
47785 { "HERODROWNCMB", HERODROWNCMB, 0, 0 },
47786 { "NPCFAKEZ", NPCFAKEZ, 0, 0 },
47787 { "ITEMFAKEZ", ITEMFAKEZ, 0, 0 },
47788 { "LWPNFAKEZ", LWPNFAKEZ, 0, 0 },
47789 { "EWPNFAKEZ", EWPNFAKEZ, 0, 0 },
47790 { "HEROFAKEZ", HEROFAKEZ, 0, 0 },
47791 { "NPCFAKEJUMP", NPCFAKEJUMP, 0, 0 },
47792 { "ITEMFAKEJUMP", ITEMFAKEJUMP, 0, 0 },
47793 { "LWPNFAKEJUMP", LWPNFAKEJUMP, 0, 0 },
47794 { "EWPNFAKEJUMP", EWPNFAKEJUMP, 0, 0 },
47795 { "HEROFAKEJUMP", HEROFAKEJUMP, 0, 0 },
47796 { "HEROSHADOWXOFS", HEROSHADOWXOFS, 0, 0 },
47797 { "HEROSHADOWYOFS", HEROSHADOWYOFS, 0, 0 },
47798 { "NPCSHADOWXOFS", NPCSHADOWXOFS, 0, 0 },
47799 { "NPCSHADOWYOFS", NPCSHADOWYOFS, 0, 0 },
47800 { "ITEMSHADOWXOFS", ITEMSHADOWXOFS, 0, 0 },
47801 { "ITEMSHADOWYOFS", ITEMSHADOWYOFS, 0, 0 },
47802 { "LWPNSHADOWXOFS", LWPNSHADOWXOFS, 0, 0 },
47803 { "LWPNSHADOWYOFS", LWPNSHADOWYOFS, 0, 0 },
47804 { "EWPNSHADOWXOFS", EWPNSHADOWXOFS, 0, 0 },
47805 { "EWPNSHADOWYOFS", EWPNSHADOWYOFS, 0, 0 },
47806 { "LWPNDEGANGLE", LWPNDEGANGLE, 0, 0 },
47807 { "EWPNDEGANGLE", EWPNDEGANGLE, 0, 0 },
47808 { "LWPNVX", LWPNVX, 0, 0 },
47809 { "LWPNVY", LWPNVY, 0, 0 },
47810 { "EWPNVX", EWPNVX, 0, 0 },
47811 { "EWPNVY", EWPNVY, 0, 0 },
47812 { "LWPNAUTOROTATE", LWPNAUTOROTATE, 0, 0 },
47813 { "EWPNAUTOROTATE", EWPNAUTOROTATE, 0, 0 },
47814 { "IDATACOSTCOUNTER2", IDATACOSTCOUNTER2, 0, 0 },
47815 { "IDATAMAGICTIMER2", IDATAMAGICTIMER2, 0, 0 },
47816 { "IDATACOST2", IDATACOST2, 0, 0 },
47817 { "IDATAVALIDATE2", IDATAVALIDATE2, 0, 0 },
47818 { "MESSAGEDATATEXTLEN", MESSAGEDATATEXTLEN, 0, 0 },
47819 { "LWPNFLAGS", LWPNFLAGS, 0, 0 },
47820 { "EWPNFLAGS", EWPNFLAGS, 0, 0 },
47821 { "REFSTACK", REFSTACK, 0, 0 },
47822 { "STACKSIZE", STACKSIZE, 0, 0 },
47823 { "STACKFULL", STACKFULL, 0, 0 },
47824 { "ITEMFORCEGRAB", ITEMFORCEGRAB, 0, 0 },
47825 { "COMBODTRIGGERITEM", COMBODTRIGGERITEM, 0, 0 },
47826 { "COMBODTRIGGERTIMER", COMBODTRIGGERTIMER, 0, 0 },
47827 { "COMBODTRIGGERSFX", COMBODTRIGGERSFX, 0, 0 },
47828 { "COMBODTRIGGERCHANGECMB", COMBODTRIGGERCHANGECMB, 0, 0 },
47829 { "SCREENEXSTATED", SCREENEXSTATED, 0, 0 },
47830 { "MAPDATAEXSTATED", MAPDATAEXSTATED, 0, 0 },
47831 { "HEROSTANDING", HEROSTANDING, 0, 0 },
47832 { "COMBODTRIGGERPROX", COMBODTRIGGERPROX, 0, 0 },
47833 { "COMBODTRIGGERLIGHTBEAM", COMBODTRIGGERLIGHTBEAM, 0, 0 },
47834 { "COMBODTRIGGERCTR", COMBODTRIGGERCTR, 0, 0 },
47835 { "COMBODTRIGGERCTRAMNT", COMBODTRIGGERCTRAMNT, 0, 0 },
47836 { "GENDATAEVENTSTATE", GENDATAEVENTSTATE, 0, 0 },
47837 { "GAMEEVENTDATA", GAMEEVENTDATA, 0, 0 },
47838 { "ITEMDROPPEDBY", ITEMDROPPEDBY, 0, 0 },
47839 { "GAMEGSWITCH", GAMEGSWITCH, 0, 0 },
47840
47841 { "COMBODTRIGGERCOOLDOWN", COMBODTRIGGERCOOLDOWN, 0, 0 },
47842 { "COMBODTRIGGERCOPYCAT", COMBODTRIGGERCOPYCAT, 0, 0 },
47843 { "COMBODTRIGITEMPICKUP", COMBODTRIGITEMPICKUP, 0, 0 },
47844 { "COMBODTRIGEXSTATE", COMBODTRIGEXSTATE, 0, 0 },
47845 { "COMBODTRIGSPAWNENEMY", COMBODTRIGSPAWNENEMY, 0, 0 },
47846 { "COMBODTRIGSPAWNITEM", COMBODTRIGSPAWNITEM, 0, 0 },
47847 { "COMBODTRIGCSETCHANGE", COMBODTRIGCSETCHANGE, 0, 0 },
47848 { "COMBODLIFTGFXCOMBO", COMBODLIFTGFXCOMBO, 0, 0 },
47849 { "COMBODLIFTGFXCCSET", COMBODLIFTGFXCCSET, 0, 0 },
47850 { "COMBODLIFTUNDERCMB", COMBODLIFTUNDERCMB, 0, 0 },
47851 { "COMBODLIFTUNDERCS", COMBODLIFTUNDERCS, 0, 0 },
47852 { "COMBODLIFTDAMAGE", COMBODLIFTDAMAGE, 0, 0 },
47853 { "COMBODLIFTLEVEL", COMBODLIFTLEVEL, 0, 0 },
47854 { "COMBODLIFTITEM", COMBODLIFTITEM, 0, 0 },
47855 { "COMBODLIFTFLAGS", COMBODLIFTFLAGS, 0, 0 },
47856 { "COMBODLIFTGFXTYPE", COMBODLIFTGFXTYPE, 0, 0 },
47857 { "COMBODLIFTGFXSPRITE", COMBODLIFTGFXSPRITE, 0, 0 },
47858 { "COMBODLIFTSFX", COMBODLIFTSFX, 0, 0 },
47859 { "COMBODLIFTBREAKSPRITE", COMBODLIFTBREAKSPRITE, 0, 0 },
47860 { "COMBODLIFTBREAKSFX", COMBODLIFTBREAKSFX, 0, 0 },
47861 { "COMBODLIFTHEIGHT", COMBODLIFTHEIGHT, 0, 0 },
47862 { "COMBODLIFTTIME", COMBODLIFTTIME, 0, 0 },
47863 { "CLASS_THISKEY", CLASS_THISKEY, 0, 0 },
47864 { "ZELDABETATYPE", ZELDABETATYPE, 0, 0 },
47865 { "HEROCOYOTETIME", HEROCOYOTETIME, 0, 0 },
47866 { "FFCLASTCHANGERX", FFCLASTCHANGERX, 0, 0 },
47867 { "FFCLASTCHANGERY", FFCLASTCHANGERY, 0, 0 },
47868 { "LWPNTIMEOUT", LWPNTIMEOUT, 0, 0 },
47869 { "EWPNTIMEOUT", EWPNTIMEOUT, 0, 0 },
47870 { "COMBODTRIGGERLSTATE", COMBODTRIGGERLSTATE, 0, 0 },
47871 { "COMBODTRIGGERGSTATE", COMBODTRIGGERGSTATE, 0, 0 },
47872 { "COMBODTRIGGERGTIMER", COMBODTRIGGERGTIMER, 0, 0 },
47873 { "GAMEMOUSECURSOR", GAMEMOUSECURSOR, 0, 0 },
47874 { "COMBODTRIGGERGENSCRIPT", COMBODTRIGGERGENSCRIPT, 0, 0 },
47875 { "COMBODTRIGGERGROUP", COMBODTRIGGERGROUP, 0, 0 },
47876 { "COMBODTRIGGERGROUPVAL", COMBODTRIGGERGROUPVAL, 0, 0 },
47877 { "HEROLIFTEDWPN", HEROLIFTEDWPN, 0, 0 },
47878 { "HEROLIFTTIMER", HEROLIFTTIMER, 0, 0 },
47879 { "HEROLIFTMAXTIMER", HEROLIFTMAXTIMER, 0, 0 },
47880 { "HEROLIFTHEIGHT", HEROLIFTHEIGHT, 0, 0 },
47881 { "HEROHAMMERSTATE", HEROHAMMERSTATE, 0, 0 },
47882 { "HEROLIFTFLAGS", HEROLIFTFLAGS, 0, 0 },
47883 { "COMBODLIFTWEAPONITEM", COMBODLIFTWEAPONITEM, 0, 0 },
47884 { "LWPNDEATHITEM", LWPNDEATHITEM, 0, 0 },
47885 { "LWPNDEATHDROPSET", LWPNDEATHDROPSET, 0, 0 },
47886 { "LWPNDEATHIPICKUP", LWPNDEATHIPICKUP, 0, 0 },
47887 { "LWPNDEATHSPRITE", LWPNDEATHSPRITE, 0, 0 },
47888 { "LWPNDEATHSFX", LWPNDEATHSFX, 0, 0 },
47889 { "EWPNDEATHITEM", EWPNDEATHITEM, 0, 0 },
47890 { "EWPNDEATHDROPSET", EWPNDEATHDROPSET, 0, 0 },
47891 { "EWPNDEATHIPICKUP", EWPNDEATHIPICKUP, 0, 0 },
47892 { "EWPNDEATHSPRITE", EWPNDEATHSPRITE, 0, 0 },
47893 { "EWPNDEATHSFX", EWPNDEATHSFX, 0, 0 },
47894
47895 { "REFPALDATA", REFPALDATA, 0, 0 },
47896
47897 { "PALDATACOLOR", PALDATACOLOR, 0, 0 },
47898 { "PALDATAR", PALDATAR, 0, 0 },
47899 { "PALDATAG", PALDATAG, 0, 0 },
47900 { "PALDATAB", PALDATAB, 0, 0 },
47901
47902 { "DMAPDATALOOPSTART", DMAPDATALOOPSTART, 0, 0 },
47903 { "DMAPDATALOOPEND", DMAPDATALOOPEND, 0, 0 },
47904 { "DMAPDATAXFADEIN", DMAPDATAXFADEIN, 0, 0 },
47905 { "DMAPDATAXFADEOUT", DMAPDATAXFADEOUT, 0, 0 },
47906 { "MUSICUPDATECOND", MUSICUPDATECOND, 0, 0 },
47907 { "MUSICUPDATEFLAGS", MUSICUPDATEFLAGS, 0, 0 },
47908 { "DMAPDATAINTROSTRINGID", DMAPDATAINTROSTRINGID, 0, 0 },
47909 { "RESRVD_VAR_MOOSH08", RESRVD_VAR_MOOSH08, 0, 0 },
47910 { "RESRVD_VAR_MOOSH09", RESRVD_VAR_MOOSH09, 0, 0 },
47911 { "RESRVD_VAR_MOOSH10", RESRVD_VAR_MOOSH10, 0, 0 },
47912 { "RESRVD_VAR_MOOSH11", RESRVD_VAR_MOOSH11, 0, 0 },
47913 { "RESRVD_VAR_MOOSH12", RESRVD_VAR_MOOSH12, 0, 0 },
47914 { "RESRVD_VAR_MOOSH13", RESRVD_VAR_MOOSH13, 0, 0 },
47915 { "RESRVD_VAR_MOOSH14", RESRVD_VAR_MOOSH14, 0, 0 },
47916 { "RESRVD_VAR_MOOSH15", RESRVD_VAR_MOOSH15, 0, 0 },
47917 { "RESRVD_VAR_MOOSH16", RESRVD_VAR_MOOSH16, 0, 0 },
47918 { "RESRVD_VAR_MOOSH17", RESRVD_VAR_MOOSH17, 0, 0 },
47919 { "RESRVD_VAR_MOOSH18", RESRVD_VAR_MOOSH18, 0, 0 },
47920 { "RESRVD_VAR_MOOSH19", RESRVD_VAR_MOOSH19, 0, 0 },
47921 { "RESRVD_VAR_MOOSH20", RESRVD_VAR_MOOSH20, 0, 0 },
47922 { "RESRVD_VAR_MOOSH21", RESRVD_VAR_MOOSH21, 0, 0 },
47923 { "RESRVD_VAR_MOOSH22", RESRVD_VAR_MOOSH22, 0, 0 },
47924 { "RESRVD_VAR_MOOSH23", RESRVD_VAR_MOOSH23, 0, 0 },
47925 { "RESRVD_VAR_MOOSH24", RESRVD_VAR_MOOSH24, 0, 0 },
47926 { "RESRVD_VAR_MOOSH25", RESRVD_VAR_MOOSH25, 0, 0 },
47927 { "RESRVD_VAR_MOOSH26", RESRVD_VAR_MOOSH26, 0, 0 },
47928 { "RESRVD_VAR_MOOSH27", RESRVD_VAR_MOOSH27, 0, 0 },
47929 { "RESRVD_VAR_MOOSH28", RESRVD_VAR_MOOSH28, 0, 0 },
47930 { "RESRVD_VAR_MOOSH29", RESRVD_VAR_MOOSH29, 0, 0 },
47931 { "RESRVD_VAR_MOOSH30", RESRVD_VAR_MOOSH30, 0, 0 },
47932 { "DMAPDATAMIRRDMAP", DMAPDATAMIRRDMAP, 0, 0 },
47933 { "IDATAGRADUAL", IDATAGRADUAL, 0, 0 },
47934 { "IDATASPRSCRIPT", IDATASPRSCRIPT, 0, 0 },
47935 { "IDATAPSOUND", IDATAPSOUND, 0, 0 },
47936 { "IDATACONSTSCRIPT", IDATACONSTSCRIPT, 0, 0 },
47937 { "IDATASSWIMDISABLED", IDATASSWIMDISABLED, 0, 0 },
47938 { "IDATABUNNYABLE", IDATABUNNYABLE, 0, 0 },
47939 { "IDATAJINXIMMUNE", IDATAJINXIMMUNE, 0, 0 },
47940 { "IDATAJINXSWAP", IDATAJINXSWAP, 0, 0 },
47941 { "SPRITEDATAFLCSET", SPRITEDATAFLCSET, 0, 0 },
47942 { "SPRITEDATAFLAGS", SPRITEDATAFLAGS, 0, 0 },
47943 { "SPRITEDATAID", SPRITEDATAID, 0, 0 },
47944 { "CLASS_THISKEY2", CLASS_THISKEY2, 0, 0 },
47945 { "RESRVD_VAR_Z3_01", RESRVD_VAR_Z3_01, 0, 0 },
47946 { "RESRVD_VAR_Z3_02", RESRVD_VAR_Z3_02, 0, 0 },
47947 { "RESRVD_VAR_Z3_03", RESRVD_VAR_Z3_03, 0, 0 },
47948 { "RESRVD_VAR_Z3_04", RESRVD_VAR_Z3_04, 0, 0 },
47949 { "RESRVD_VAR_Z3_05", RESRVD_VAR_Z3_05, 0, 0 },
47950 { "RESRVD_VAR_Z3_06", RESRVD_VAR_Z3_06, 0, 0 },
47951 { "RESRVD_VAR_Z3_07", RESRVD_VAR_Z3_07, 0, 0 },
47952 { "RESRVD_VAR_Z3_08", RESRVD_VAR_Z3_08, 0, 0 },
47953 { "RESRVD_VAR_Z3_09", RESRVD_VAR_Z3_09, 0, 0 },
47954 { "RESRVD_VAR_Z3_10", RESRVD_VAR_Z3_10, 0, 0 },
47955 { "RESRVD_VAR_Z3_11", RESRVD_VAR_Z3_11, 0, 0 },
47956 { "RESRVD_VAR_Z3_12", RESRVD_VAR_Z3_12, 0, 0 },
47957 { "RESRVD_VAR_Z3_13", RESRVD_VAR_Z3_13, 0, 0 },
47958 { "RESRVD_VAR_Z3_14", RESRVD_VAR_Z3_14, 0, 0 },
47959 { "RESRVD_VAR_Z3_15", RESRVD_VAR_Z3_15, 0, 0 },
47960 { "RESRVD_VAR_Z3_16", RESRVD_VAR_Z3_16, 0, 0 },
47961 { "LWPNLIFTLEVEL", LWPNLIFTLEVEL, 0, 0},
47962 { "LWPNLIFTTIME", LWPNLIFTTIME, 0, 0},
47963 { "LWPNLIFTHEIGHT", LWPNLIFTHEIGHT, 0, 0},
47964 { "EWPNLIFTLEVEL", EWPNLIFTLEVEL, 0, 0},
47965 { "EWPNLIFTTIME", EWPNLIFTTIME, 0, 0},
47966 { "EWPNLIFTHEIGHT", EWPNLIFTHEIGHT, 0, 0},
47967 { "HEROSHIELDJINX", HEROSHIELDJINX, 0, 0},
47968 { "MAPDATALENSSHOWS", MAPDATALENSSHOWS, 0, 0},
47969 { "MAPDATALENSHIDES", MAPDATALENSHIDES, 0, 0},
47970 { "SCREENLENSSHOWS", SCREENLENSSHOWS, 0, 0},
47971 { "SCREENLENSHIDES", SCREENLENSHIDES, 0, 0},
47972 { "GAMETRIGGROUPS", GAMETRIGGROUPS, 0, 0},
47973 { "GAMEOVERRIDEITEMS", GAMEOVERRIDEITEMS, 0, 0},
47974 { "DMAPDATASUBSCRO", DMAPDATASUBSCRO, 0, 0},
47975 { "REFSUBSCREENPAGE", REFSUBSCREENPAGE, 0, 0},
47976 { "REFSUBSCREENWIDG", REFSUBSCREENWIDG, 0, 0},
47977 { "SUBDATACURPG", SUBDATACURPG, 0, 0},
47978 { "SUBDATANUMPG", SUBDATANUMPG, 0, 0},
47979 { "SUBDATAPAGES", SUBDATAPAGES, 0, 0},
47980 { "SUBDATATYPE", SUBDATATYPE, 0, 0},
47981 { "SUBDATAFLAGS", SUBDATAFLAGS, 0, 0},
47982 { "SUBDATACURSORPOS", SUBDATACURSORPOS, 0, 0},
47983 { "SUBDATASCRIPT", SUBDATASCRIPT, 0, 0},
47984 { "SUBDATAINITD", SUBDATAINITD, 0, 0},
47985 { "SUBDATABTNLEFT", SUBDATABTNLEFT, 0, 0},
47986 { "SUBDATABTNRIGHT", SUBDATABTNRIGHT, 0, 0},
47987 { "SUBDATATRANSLEFTTY", SUBDATATRANSLEFTTY, 0, 0},
47988 { "SUBDATATRANSLEFTSFX", SUBDATATRANSLEFTSFX, 0, 0},
47989 { "SUBDATATRANSLEFTFLAGS", SUBDATATRANSLEFTFLAGS, 0, 0},
47990 { "SUBDATATRANSLEFTARGS", SUBDATATRANSLEFTARGS, 0, 0},
47991 { "PORTALX", PORTALX, 0, 0},
47992 { "PORTALY", PORTALY, 0, 0},
47993 { "PORTALDMAP", PORTALDMAP, 0, 0},
47994 { "PORTALSCREEN", PORTALSCREEN, 0, 0},
47995 { "PORTALACLK", PORTALACLK, 0, 0},
47996 { "PORTALAFRM", PORTALAFRM, 0, 0},
47997 { "PORTALOTILE", PORTALOTILE, 0, 0},
47998 { "PORTALASPD", PORTALASPD, 0, 0},
47999 { "PORTALFRAMES", PORTALFRAMES, 0, 0},
48000 { "PORTALSAVED", PORTALSAVED, 0, 0},
48001 { "PORTALCLOSEDIS", PORTALCLOSEDIS, 0, 0},
48002 { "REFPORTAL", REFPORTAL, 0, 0},
48003 { "REFSAVPORTAL", REFSAVPORTAL, 0, 0},
48004 { "PORTALWARPSFX", PORTALWARPSFX, 0, 0},
48005 { "PORTALWARPVFX", PORTALWARPVFX, 0, 0},
48006 { "SAVEDPORTALX", SAVEDPORTALX, 0, 0},
48007 { "SAVEDPORTALY", SAVEDPORTALY, 0, 0},
48008 { "SAVEDPORTALSRCDMAP", SAVEDPORTALSRCDMAP, 0, 0},
48009 { "SAVEDPORTALDESTDMAP", SAVEDPORTALDESTDMAP, 0, 0},
48010 { "SAVEDPORTALSRCSCREEN", SAVEDPORTALSRCSCREEN, 0, 0},
48011 { "SAVEDPORTALWARPSFX", SAVEDPORTALWARPSFX, 0, 0},
48012 { "SAVEDPORTALWARPVFX", SAVEDPORTALWARPVFX, 0, 0},
48013 { "SAVEDPORTALSPRITE", SAVEDPORTALSPRITE, 0, 0},
48014 { "SAVEDPORTALPORTAL", SAVEDPORTALPORTAL, 0, 0},
48015 { "PORTALCOUNT", PORTALCOUNT, 0, 0},
48016 { "SAVEDPORTALCOUNT", SAVEDPORTALCOUNT, 0, 0},
48017 { "SAVEDPORTALDSTSCREEN", SAVEDPORTALDSTSCREEN, 0, 0},
48018
48019 { "SUBDATATRANSRIGHTTY", SUBDATATRANSRIGHTTY, 0, 0 },
48020 { "SUBDATATRANSRIGHTSFX", SUBDATATRANSRIGHTSFX, 0, 0 },
48021 { "SUBDATATRANSRIGHTFLAGS", SUBDATATRANSRIGHTFLAGS, 0, 0 },
48022 { "SUBDATATRANSRIGHTARGS", SUBDATATRANSRIGHTARGS, 0, 0 },
48023 { "SUBDATASELECTORDSTX", SUBDATASELECTORDSTX, 0, 0 },
48024 { "SUBDATASELECTORDSTY", SUBDATASELECTORDSTY, 0, 0 },
48025 { "SUBDATASELECTORDSTW", SUBDATASELECTORDSTW, 0, 0 },
48026 { "SUBDATASELECTORDSTH", SUBDATASELECTORDSTH, 0, 0 },
48027 { "SUBDATASELECTORWID", SUBDATASELECTORWID, 0, 0 },
48028 { "SUBDATASELECTORHEI", SUBDATASELECTORHEI, 0, 0 },
48029 { "SUBDATASELECTORTILE", SUBDATASELECTORTILE, 0, 0 },
48030 { "SUBDATASELECTORCSET", SUBDATASELECTORCSET, 0, 0 },
48031 { "SUBDATASELECTORFRM", SUBDATASELECTORFRM, 0, 0 },
48032 { "SUBDATASELECTORASPD", SUBDATASELECTORASPD, 0, 0 },
48033 { "SUBDATASELECTORDELAY", SUBDATASELECTORDELAY, 0, 0 },
48034 { "SUBDATATRANSCLK", SUBDATATRANSCLK, 0, 0 },
48035 { "SUBDATATRANSTY", SUBDATATRANSTY, 0, 0 },
48036 { "SUBDATATRANSFLAGS", SUBDATATRANSFLAGS, 0, 0 },
48037 { "SUBDATATRANSARGS", SUBDATATRANSARGS, 0, 0 },
48038 { "SUBDATATRANSFROMPG", SUBDATATRANSFROMPG, 0, 0 },
48039 { "SUBDATATRANSTOPG", SUBDATATRANSTOPG, 0, 0 },
48040 { "SUBDATASELECTORFLASHCSET", SUBDATASELECTORFLASHCSET, 0, 0 },
48041 { "GAMEASUBOPEN", GAMEASUBOPEN, 0, 0 },
48042 { "GAMENUMASUB", GAMENUMASUB, 0, 0 },
48043 { "GAMENUMPSUB", GAMENUMPSUB, 0, 0 },
48044 { "GAMENUMOSUB", GAMENUMOSUB, 0, 0 },
48045 { "SUBPGINDEX", SUBPGINDEX, 0, 0 },
48046 { "SUBPGNUMWIDG", SUBPGNUMWIDG, 0, 0 },
48047 { "SUBPGWIDGETS", SUBPGWIDGETS, 0, 0 },
48048 { "SUBPGSUBDATA", SUBPGSUBDATA, 0, 0 },
48049 { "SUBPGCURSORPOS", SUBPGCURSORPOS, 0, 0 },
48050 { "SUBWIDGTYPE", SUBWIDGTYPE, 0, 0 },
48051 { "SUBWIDGINDEX", SUBWIDGINDEX, 0, 0 },
48052 { "SUBWIDGPAGE", SUBWIDGPAGE, 0, 0 },
48053 { "SUBWIDGPOS", SUBWIDGPOS, 0, 0 },
48054 { "SUBWIDGPOSES", SUBWIDGPOSES, 0, 0 },
48055 { "SUBWIDGPOSFLAG", SUBWIDGPOSFLAG, 0, 0 },
48056 { "SUBWIDGX", SUBWIDGX, 0, 0 },
48057 { "SUBWIDGY", SUBWIDGY, 0, 0 },
48058 { "SUBWIDGW", SUBWIDGW, 0, 0 },
48059 { "SUBWIDGH", SUBWIDGH, 0, 0 },
48060 { "SUBWIDGGENFLAG", SUBWIDGGENFLAG, 0, 0 },
48061 { "SUBWIDGFLAG", SUBWIDGFLAG, 0, 0 },
48062 { "SUBWIDGSELECTORDSTX", SUBWIDGSELECTORDSTX, 0, 0 },
48063 { "SUBWIDGSELECTORDSTY", SUBWIDGSELECTORDSTY, 0, 0 },
48064 { "SUBWIDGSELECTORDSTW", SUBWIDGSELECTORDSTW, 0, 0 },
48065 { "SUBWIDGSELECTORDSTH", SUBWIDGSELECTORDSTH, 0, 0 },
48066 { "SUBWIDGSELECTORWID", SUBWIDGSELECTORWID, 0, 0 },
48067 { "SUBWIDGSELECTORHEI", SUBWIDGSELECTORHEI, 0, 0 },
48068 { "SUBWIDGSELECTORTILE", SUBWIDGSELECTORTILE, 0, 0 },
48069
48070 { "SUBWIDGSELECTORCSET", SUBWIDGSELECTORCSET, 0, 0 },
48071 { "SUBWIDGSELECTORFLASHCSET", SUBWIDGSELECTORFLASHCSET, 0, 0 },
48072 { "SUBWIDGSELECTORFRM", SUBWIDGSELECTORFRM, 0, 0 },
48073 { "SUBWIDGSELECTORASPD", SUBWIDGSELECTORASPD, 0, 0 },
48074 { "SUBWIDGSELECTORDELAY", SUBWIDGSELECTORDELAY, 0, 0 },
48075 { "SUBWIDGPRESSSCRIPT", SUBWIDGPRESSSCRIPT, 0, 0 },
48076 { "SUBWIDGPRESSINITD", SUBWIDGPRESSINITD, 0, 0 },
48077 { "SUBWIDGBTNPRESS", SUBWIDGBTNPRESS, 0, 0 },
48078 { "SUBWIDGBTNPG", SUBWIDGBTNPG, 0, 0 },
48079 { "SUBWIDGPGMODE", SUBWIDGPGMODE, 0, 0 },
48080 { "SUBWIDGPGTARG", SUBWIDGPGTARG, 0, 0 },
48081 { "SUBWIDGTRANSPGTY", SUBWIDGTRANSPGTY, 0, 0 },
48082 { "SUBWIDGTRANSPGSFX", SUBWIDGTRANSPGSFX, 0, 0 },
48083 { "SUBWIDGTRANSPGFLAGS", SUBWIDGTRANSPGFLAGS, 0, 0 },
48084 { "SUBWIDGTRANSPGARGS", SUBWIDGTRANSPGARGS, 0, 0 },
48085
48086 { "SUBWIDGTY_CSET", SUBWIDGTY_CSET, 0, 0 },
48087 { "SUBWIDGTY_TILE", SUBWIDGTY_TILE, 0, 0 },
48088
48089 { "SUBWIDGTY_FONT", SUBWIDGTY_FONT, 0, 0 },
48090 { "SUBWIDGTY_ALIGN", SUBWIDGTY_ALIGN, 0, 0 },
48091 { "SUBWIDGTY_SHADOWTY", SUBWIDGTY_SHADOWTY, 0, 0 },
48092 { "SUBWIDGTY_COLOR_TXT", SUBWIDGTY_COLOR_TXT, 0, 0 },
48093 { "SUBWIDGTY_COLOR_SHD", SUBWIDGTY_COLOR_SHD, 0, 0 },
48094 { "SUBWIDGTY_COLOR_BG", SUBWIDGTY_COLOR_BG, 0, 0 },
48095
48096 { "SUBWIDGTY_COLOR_OLINE", SUBWIDGTY_COLOR_OLINE, 0, 0 },
48097 { "SUBWIDGTY_COLOR_FILL", SUBWIDGTY_COLOR_FILL, 0, 0 },
48098
48099 { "SUBWIDGTY_BUTTON", SUBWIDGTY_BUTTON, 0, 0 },
48100 { "SUBWIDGTY_COUNTERS", SUBWIDGTY_COUNTERS, 0, 0 },
48101 { "SUBWIDGTY_MINDIG", SUBWIDGTY_MINDIG, 0, 0 },
48102 { "SUBWIDGTY_MAXDIG", SUBWIDGTY_MAXDIG, 0, 0 },
48103 { "SUBWIDGTY_INFITM", SUBWIDGTY_INFITM, 0, 0 },
48104 { "SUBWIDGTY_INFCHAR", SUBWIDGTY_INFCHAR, 0, 0 },
48105 { "SUBWIDGTY_COSTIND", SUBWIDGTY_COSTIND, 0, 0 },
48106
48107 { "SUBWIDGTY_COLOR_PLAYER", SUBWIDGTY_COLOR_PLAYER, 0, 0 },
48108 { "SUBWIDGTY_COLOR_CMPBLNK", SUBWIDGTY_COLOR_CMPBLNK, 0, 0 },
48109 { "SUBWIDGTY_COLOR_CMPOFF", SUBWIDGTY_COLOR_CMPOFF, 0, 0 },
48110 { "SUBWIDGTY_COLOR_ROOM", SUBWIDGTY_COLOR_ROOM, 0, 0 },
48111 { "SUBWIDGTY_ITEMCLASS", SUBWIDGTY_ITEMCLASS, 0, 0 },
48112 { "SUBWIDGTY_ITEMID", SUBWIDGTY_ITEMID, 0, 0 },
48113 { "SUBWIDGTY_FRAMETILE", SUBWIDGTY_FRAMETILE, 0, 0 },
48114 { "SUBWIDGTY_FRAMECSET", SUBWIDGTY_FRAMECSET, 0, 0 },
48115 { "SUBWIDGTY_PIECETILE", SUBWIDGTY_PIECETILE, 0, 0 },
48116 { "SUBWIDGTY_PIECECSET", SUBWIDGTY_PIECECSET, 0, 0 },
48117 { "SUBWIDGTY_FLIP", SUBWIDGTY_FLIP, 0, 0 },
48118 { "SUBWIDGTY_NUMBER", SUBWIDGTY_NUMBER, 0, 0 },
48119 { "SUBWIDGTY_CORNER", SUBWIDGTY_CORNER, 0, 0 },
48120
48121 { "SUBWIDGTY_FRAMES", SUBWIDGTY_FRAMES, 0, 0 },
48122 { "SUBWIDGTY_SPEED", SUBWIDGTY_SPEED, 0, 0 },
48123 { "SUBWIDGTY_DELAY", SUBWIDGTY_DELAY, 0, 0 },
48124 { "SUBWIDGTY_CONTAINER", SUBWIDGTY_CONTAINER, 0, 0 },
48125 { "SUBWIDGTY_GAUGE_WID", SUBWIDGTY_GAUGE_WID, 0, 0 },
48126 { "SUBWIDGTY_GAUGE_HEI", SUBWIDGTY_GAUGE_HEI, 0, 0 },
48127 { "SUBWIDGTY_UNITS", SUBWIDGTY_UNITS, 0, 0 },
48128 { "SUBWIDGTY_HSPACE", SUBWIDGTY_HSPACE, 0, 0 },
48129 { "SUBWIDGTY_VSPACE", SUBWIDGTY_VSPACE, 0, 0 },
48130 { "SUBWIDGTY_GRIDX", SUBWIDGTY_GRIDX, 0, 0 },
48131 { "SUBWIDGTY_GRIDY", SUBWIDGTY_GRIDY, 0, 0 },
48132 { "SUBWIDGTY_ANIMVAL", SUBWIDGTY_ANIMVAL, 0, 0 },
48133 { "SUBWIDGTY_SHOWDRAIN", SUBWIDGTY_SHOWDRAIN, 0, 0 },
48134 { "SUBWIDGTY_PERCONTAINER", SUBWIDGTY_PERCONTAINER, 0, 0 },
48135 { "SUBWIDGTY_TABSIZE", SUBWIDGTY_TABSIZE, 0, 0 },
48136
48137 { "GAMEASUBYOFF", GAMEASUBYOFF, 0, 0 },
48138
48139 { "SUBWIDGDISPITM", SUBWIDGDISPITM, 0, 0 },
48140 { "SUBWIDGEQPITM", SUBWIDGEQPITM, 0, 0 },
48141
48142 { "SUBWIDG_DISPX", SUBWIDG_DISPX, 0, 0 },
48143 { "SUBWIDG_DISPY", SUBWIDG_DISPY, 0, 0 },
48144 { "SUBWIDG_DISPW", SUBWIDG_DISPW, 0, 0 },
48145 { "SUBWIDG_DISPH", SUBWIDG_DISPH, 0, 0 },
48146
48147 { "SCREENSCRDATASIZE", SCREENSCRDATASIZE, 0, 0 },
48148 { "SCREENSCRDATA", SCREENSCRDATA, 0, 0 },
48149 { "MAPDATASCRDATASIZE", MAPDATASCRDATASIZE, 0, 0 },
48150 { "MAPDATASCRDATA", MAPDATASCRDATA, 0, 0 },
48151
48152 { "HEROSHOVEOFFSET", HEROSHOVEOFFSET, 0, 0 },
48153
48154 { " ", -1, 0, 0 }
48155 };
48156
48157
48158
48159 ///----------------------------------------------------------------------------------------------------//
48160 //Debugger and Logging Consoles
48161
48162 template <typename ...Params>
48163 void FFScript::ZScriptConsole(int32_t attributes,const char *format, Params&&... params)
48164 {
48165 //if ( open )
48166 {
48167 zscript_coloured_console.Create("ZQuest Creator Logging Console", 600, 200, NULL, NULL);
48168 zscript_coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
48169 zscript_coloured_console.gotoxy(0,0);
48170 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
48171 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"ZQuest Creator Logging Console\n");
48172
48173 zscript_coloured_console.cprintf( attributes, format, std::forward<Params>(params)...);
48174 }
48175 //else
48176 //{
48177 //close
48178 // zscript_coloured_console.Close();
48179 //}
48180 }
48181
48182 124 void clearConsole()
48183 {
48184 124 zscript_coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
48185 124 zscript_coloured_console.gotoxy(0,0);
48186
48187 124 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
48188 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"\n _____ ____ __ \n");
48189 124 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
48190 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK," /__ / / __ \\__ _____ _____/ /_\n");
48191 124 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
48192 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK," / / / / / / / / / _ \\/ ___/ __/\n");
48193 124 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
48194 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK," / /__/ /_/ / /_/ / __(__ ) /_ \n");
48195 124 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
48196 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK," /____/\\___\\_\\__,_/\\___/____/\\__/\n\n");
48197
48198 124 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
48199 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Quest Data Logging & ZScript Debug Console\n");
48200
48201 124 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE |CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
48202 124 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Running: %s\n", getProgramVerStr());
48203
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 8 times.
124 if ( FFCore.getQuestHeaderInfo(vZelda) > 0 )
48204 {
48205 8 char const* verstr = QHeader.getVerStr();
48206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(verstr[0])
48207 {
48208 8 auto vercmp = QHeader.compareVer();
48209 8 auto astatecmp = compare(int32_t(QHeader.getAlphaState()), ALPHA_STATE);
48210 8 auto avercmp = compare(QHeader.getAlphaVer(), ALPHA_VER);
48211 8 auto timecmp = QHeader.compareDate();
48212
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
8 if(!(vercmp || astatecmp || avercmp))
48213 {
48214 if(!timecmp || !QHeader.new_version_is_nightly)
48215 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE |CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
48216 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Quest Made in this build\n", verstr);
48217 else if(timecmp < 0)
48218 {
48219 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE |CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
48220 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Quest Made in an earlier nightly of the same build\n", verstr);
48221 }
48222 else
48223 {
48224 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE |CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
48225 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Quest Made in an LATER nightly of the same build!\n"
48226 "This may be unsafe to play in this version!\n", verstr);
48227 }
48228 }
48229 8 else zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE |CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
48230 8 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Quest Made in: %s\n", verstr);
48231 8 }
48232 8 }
48233 124 }
48234 void FFScript::ZScriptConsole(bool open)
48235 {
48236 if ( open )
48237 {
48238 zscript_coloured_console.Create("ZScript Debug Console", 600, 200, NULL, NULL);
48239 clearConsole();
48240 zscript_debugger = 1;
48241 }
48242 else
48243 {
48244 zscript_coloured_console.Close();
48245 zscript_debugger = 0;
48246 }
48247 zc_set_config("CONSOLE","ZScript_Debugger",zscript_debugger);
48248 }
48249
48250 void FFScript::ZASMPrint(bool open)
48251 {
48252 if(SKIPZASMPRINT()) return;
48253 zprint("%s ZASM Console\n", open ? "Opening" : "Closing");
48254 if ( open )
48255 {
48256 coloured_console.Create("ZASM Debugger", 600, 200, NULL, NULL);
48257 coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
48258 coloured_console.gotoxy(0,0);
48259 coloured_console.safeprint( CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
48260 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"ZASM Stack Trace:\n");
48261 //coloured_console.SetAsDefaultOutput();
48262 zasm_debugger = 1;
48263 zasm_break_mode = ZASM_BREAK_HALT;
48264 }
48265 else
48266 {
48267 //close
48268 coloured_console.Close();
48269 zasm_debugger = 0;
48270 }
48271 zc_set_config("CONSOLE","print_ZASM",zasm_debugger);
48272 }
48273
48274 std::string ZASMVarToString(int32_t arg)
48275 {
48276 for(int32_t q = 0; ZASMVars[q].id != -1; ++q)
48277 {
48278 if(ZASMVars[q].maxcount>0)
48279 {
48280 int32_t start = ZASMVars[q].id;
48281 int32_t mult = zc_max(1,ZASMVars[q].multiple);
48282 if(arg >= start && arg < start+(ZASMVars[q].maxcount*mult))
48283 {
48284 for(int32_t w = 0; w < ZASMVars[q].maxcount; ++w)
48285 {
48286 if(arg!=start+(w*mult)) continue;
48287
48288 char buf[64+1];
48289 if(strcmp(ZASMVars[q].name, "A")==0)
48290 sprintf(buf, "%s%d", ZASMVars[q].name, w+1);
48291 else sprintf(buf, "%s%d", ZASMVars[q].name, w);
48292 return string(buf);
48293 }
48294 }
48295 }
48296 else if(ZASMVars[q].id == arg) return string(ZASMVars[q].name);
48297 }
48298 return "(null)";
48299 }
48300
48301 void FFScript::ZASMPrintCommand(const word scommand)
48302 {
48303 if(SKIPZASMPRINT()) return;
48304 //if ( !zasm_debugger ) return;
48305
48306 script_command s_c = ZASMcommands[scommand];
48307
48308 if(s_c.args == 2)
48309 {
48310 coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
48311 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%14s: ", s_c.name);
48312
48313 if(s_c.arg1_type == 0)
48314 {
48315 coloured_console.cprintf( CConsoleLoggerEx::COLOR_WHITE |
48316 //CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %9d), ", s_v.name, get_register(sarg1));
48317 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"\t %s (val = %2d), ", ZASMVarToString(sarg1).c_str(), get_register(sarg1));
48318 }
48319 else
48320 {
48321 coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED |CConsoleLoggerEx::COLOR_INTENSITY |
48322 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %2d), ", "immediate", sarg1);
48323 }
48324 if(s_c.arg2_type == 0)
48325 {
48326 coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_INTENSITY |
48327 //CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %9d)\n", s_v.name, get_register(sarg2));
48328 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK, "\t %s (val = %2d)\n", ZASMVarToString(sarg2).c_str(), get_register(sarg2));
48329 }
48330 else
48331 {
48332 coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_INTENSITY |
48333 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %2d)\n", "immediate", sarg2);
48334 }
48335 }
48336 else if(s_c.args == 1)
48337 {
48338 coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
48339 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%14s: ", s_c.name);
48340
48341 if(s_c.arg1_type == 0)
48342 {
48343 coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_INTENSITY |
48344 //CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %9d)\n", s_v.name, get_register(sarg1));
48345 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"\t %w (val = %2d)\n", ZASMVarToString(sarg1).c_str(), get_register(sarg1));
48346 }
48347 else
48348 {
48349 coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_INTENSITY |
48350 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %2d)\n", "immediate", sarg1);
48351 }
48352 }
48353 else
48354 {
48355 coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
48356 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%14s\n",s_c.name);
48357 }
48358 //s_c.name is the string with the instruction
48359
48360 //coloured_console.print();
48361 }
48362
48363 void FFScript::ZASMPrintVarSet(const int32_t arg, int32_t argval)
48364 {
48365 if(SKIPZASMPRINT()) return;
48366
48367 //if ( !zasm_debugger ) return;
48368 // script_variable s_v = ZASMVars[arg];
48369 //s_v.name is the string with the instruction
48370 coloured_console.cprintf( CConsoleLoggerEx::COLOR_WHITE |
48371 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Set: %s\t",ZASMVarToString(arg).c_str());
48372 coloured_console.cprintf( CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
48373 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%d\n",argval);
48374 //coloured_console.print();
48375 }
48376
48377 void FFScript::ZASMPrintVarGet(const int32_t arg, int32_t argval)
48378 {
48379 if(SKIPZASMPRINT()) return;
48380
48381 //if ( !zasm_debugger ) return;
48382 // script_variable s_v = ZASMVars[arg];
48383 //s_v.name is the string with the instruction
48384 coloured_console.cprintf( CConsoleLoggerEx::COLOR_WHITE |
48385 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Get: %s\t",ZASMVarToString(arg).c_str());
48386 coloured_console.cprintf( CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
48387 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%d\n",argval);
48388 //coloured_console.print();
48389 }
48390
48391
48392
48393 ///----------------------------------------------------------------------------------------------------//
48394 //Tracing
48395
48396 3603 void FFScript::do_trace(bool v)
48397 {
48398
5/14
✗ Branch 0 not taken.
✓ Branch 1 taken 3603 times.
✓ Branch 2 taken 3603 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3603 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3603 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3603 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
7206 bool should_replay_trace = replay_is_active() && replay_get_meta_bool("script_trace");
48399 // For now, only prevent tracing to allegro log for Web version. Some quests may expect players to
48400 // look in the logs for spoiler/secret stuff.
48401 #ifdef __EMSCRIPTEN__
48402 bool should_trace = zscript_debugger || should_replay_trace;
48403 if (!should_trace) return;
48404 #endif
48405
48406 3603 int32_t temp = SH::get_arg(sarg1, v);
48407
48408 char tmp[100];
48409
1/2
✓ Branch 0 taken 3603 times.
✗ Branch 1 not taken.
3603 sprintf(tmp, (temp < 0 ? "%06d" : "%05d"), temp);
48410
1/2
✓ Branch 0 taken 3603 times.
✗ Branch 1 not taken.
3603 string s2(tmp);
48411
5/10
✓ Branch 0 taken 3603 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3603 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3603 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3603 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3603 times.
✗ Branch 9 not taken.
3603 s2 = s2.substr(0, s2.size() - 4) + "." + s2.substr(s2.size() - 4, 4) + "\n";
48412
1/2
✓ Branch 0 taken 3603 times.
✗ Branch 1 not taken.
3603 TraceScriptIDs();
48413
1/2
✓ Branch 0 taken 3603 times.
✗ Branch 1 not taken.
3603 al_trace("%s", s2.c_str());
48414
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 3594 times.
3603 if (should_replay_trace)
48415
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 replay_step_comment("trace: " + s2);
48416
48417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3603 times.
3603 if ( zscript_debugger )
48418 {
48419 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
48420 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),s2.c_str());
48421 }
48422 3603 }
48423 void FFScript::do_tracel(bool v)
48424 {
48425 int32_t temp = SH::get_arg(sarg1, v);
48426
48427 char tmp[32];
48428 sprintf(tmp, "%d\n", temp);
48429 TraceScriptIDs();
48430 al_trace("%s", tmp);
48431 if (replay_is_active() && replay_get_meta_bool("script_trace"))
48432 replay_step_comment(fmt::format("trace: {}", temp));
48433
48434 if ( zscript_debugger )
48435 {
48436 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
48437 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),tmp);
48438 }
48439 }
48440
48441 void FFScript::do_tracebool(const bool v)
48442 {
48443 int32_t temp = SH::get_arg(sarg1, v);
48444 TraceScriptIDs();
48445 char const* str = temp ? "true\n" : "false\n";
48446 al_trace("%s", str);
48447 if (replay_is_active() && replay_get_meta_bool("script_trace"))
48448 replay_step_comment(fmt::format("trace: {}", (bool)temp));
48449
48450 if ( zscript_debugger )
48451 {
48452 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
48453 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),str);
48454 }
48455 }
48456
48457 3993 void traceStr(string const& str)
48458 {
48459 3993 FFCore.TraceScriptIDs();
48460 3993 safe_al_trace(str);
48461
7/16
✗ Branch 0 not taken.
✓ Branch 1 taken 3993 times.
✓ Branch 2 taken 3993 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3993 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3993 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3993 times.
✓ Branch 10 taken 671 times.
✓ Branch 11 taken 3322 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
7986 if (replay_is_active() && replay_get_meta_bool("script_trace"))
48462
1/2
✓ Branch 0 taken 3322 times.
✗ Branch 1 not taken.
3322 replay_step_comment("trace: " + str);
48463
48464
1/2
✓ Branch 0 taken 3993 times.
✗ Branch 1 not taken.
3993 if ( zscript_debugger )
48465 {
48466 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
48467 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),str.c_str());
48468 }
48469 3993 }
48470
48471 384 void FFScript::do_tracestring()
48472 {
48473 384 int32_t arrayptr = get_register(sarg1) / 10000;
48474 384 string str;
48475
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ArrayH::getString(arrayptr, str, 512);
48476
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 str += "\0"; //In the event that the user passed an array w/o NULL, don't crash.
48477
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 traceStr(str);
48478 384 }
48479
48480 bool is_valid_format(char c)
48481 {
48482 switch(c)
48483 {
48484 case 'f': case 'd': case 'i': case 'p':
48485 case 'l': case 's': case 'c': case 'X':
48486 case 'x': case 'b': case 'B': case 'a':
48487 return true;
48488 }
48489 return false;
48490 }
48491 #define FORMATTER_FLAG_0FILL 0x01
48492 28927 char const* zs_formatter(char const* format, int32_t arg, int32_t mindig, dword flags)
48493 {
48494
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 28922 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
28927 static std::string ret;
48495
48496 28927 ret.clear();
48497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28927 times.
28927 if(format)
48498 {
48499 57854 std::string mdstr = fmt::format("%{}{}{}",(flags&FORMATTER_FLAG_0FILL)?"0":"",
48500
2/4
✓ Branch 0 taken 28927 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 28927 times.
28927 mindig, (format[0] == 'x' || format[0] == 'X') ? format[0] : 'd');
48501 28927 char const* mindigbuf = mdstr.c_str();
48502 28927 bool tempbool = false;
48503
2/12
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 20603 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 8324 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
28927 switch(format[0])
48504 {
48505 case 'f':
48506 tempbool = true;
48507 [[fallthrough]];
48508 case 'd':
48509
2/2
✓ Branch 0 taken 20131 times.
✓ Branch 1 taken 472 times.
21075 if(arg%10000)
48510 472 tempbool = true;
48511 [[fallthrough]];
48512 case 'i':
48513 case 'p':
48514 {
48515 20603 char argbuf[32] = {0};
48516 20603 bool neg = arg < 0;
48517
2/2
✓ Branch 0 taken 19201 times.
✓ Branch 1 taken 1402 times.
20603 if(mindig)
48518 1402 sprintf(argbuf,mindigbuf,arg / 10000);
48519
1/2
✓ Branch 0 taken 19201 times.
✗ Branch 1 not taken.
19201 else zc_itoa(arg / 10000, argbuf);
48520
48521
2/2
✓ Branch 0 taken 20131 times.
✓ Branch 1 taken 472 times.
20603 if(tempbool) //add decimal places
48522 {
48523 472 arg = abs(arg);
48524 472 auto ind = strlen(argbuf);
48525 472 argbuf[ind++] = '.';
48526
2/2
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 472 times.
2360 for(int div = 1000; div > 0; div /= 10)
48527 1888 argbuf[ind++] = '0' + (arg/div)%10;
48528
4/4
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 244 times.
✓ Branch 3 taken 472 times.
716 for(--ind; argbuf[ind]=='0' && argbuf[ind-1]!='-'; --ind)
48529 {
48530 244 argbuf[ind] = 0;
48531 244 }
48532 472 }
48533
48534
4/4
✓ Branch 0 taken 929 times.
✓ Branch 1 taken 19674 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 877 times.
20603 if(neg && argbuf[0] != '-')
48535
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 ret = "-";
48536
1/2
✓ Branch 0 taken 20603 times.
✗ Branch 1 not taken.
20603 ret += argbuf;
48537 20603 return ret.c_str();
48538 }
48539 //
48540 case 'l':
48541 {
48542 char argbuf[32] = {0};
48543 if(mindig)
48544 sprintf(argbuf, mindigbuf, arg);
48545 else zc_itoa(arg, argbuf);
48546
48547 ret = argbuf;
48548 return ret.c_str();
48549 }
48550 //
48551 case 's':
48552 {
48553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8324 times.
8324 if(mindig)
48554 Z_scripterrlog("Cannot use minimum digits flag for '%%s'\n");
48555
1/2
✓ Branch 0 taken 8324 times.
✗ Branch 1 not taken.
8324 if(arg)
48556 {
48557 8324 int32_t strptr = (arg / 10000);
48558
1/2
✓ Branch 0 taken 8324 times.
✗ Branch 1 not taken.
8324 ArrayManager am(strptr);
48559
2/4
✓ Branch 0 taken 8324 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8324 times.
8324 if(am.invalid())
48560 ret = "<INVALID STRING>";
48561
1/2
✓ Branch 0 taken 8324 times.
✗ Branch 1 not taken.
8324 else ArrayH::getString(strptr, ret, MAX_ZC_ARRAY_SIZE);
48562 8324 }
48563 else ret = "<NULL>";
48564 8324 return ret.c_str();
48565 }
48566 case 'c':
48567 {
48568 if(mindig)
48569 Z_scripterrlog("Cannot use minimum digits flag for '%%c'\n");
48570 int32_t c = (arg / 10000);
48571 if ( (char(c)) != c )
48572 {
48573 Z_scripterrlog("Illegal char value (%d) passed to sprintf as '%%c' arg\n", c);
48574 Z_scripterrlog("Value of invalid char will overflow.\n");
48575 }
48576 ret.push_back(char(c));
48577 return ret.c_str();
48578 }
48579 //
48580 case 'X':
48581 tempbool = true;
48582 [[fallthrough]];
48583 case 'x':
48584 {
48585 char argbuf[32] = {0};
48586 if(mindig)
48587 sprintf(argbuf,mindigbuf,arg / 10000);
48588 else zc_itoa( (arg/10000), argbuf, 16 ); //base 16; hex
48589
48590 for ( int32_t inx = 0; inx < 16; ++inx ) //set chosen caps
48591 {
48592 argbuf[inx] = ( tempbool ? toupper(argbuf[inx]) : tolower(argbuf[inx]) );
48593 }
48594 ret = "0x";
48595 ret += argbuf;
48596 return ret.c_str();
48597 }
48598 //
48599 case 'b': //int binary
48600 arg /= 10000;
48601 [[fallthrough]];
48602 case 'B': //long binary
48603 {
48604 char argbuf[33] = {0};
48605 int num_digits = mindig;
48606 for(int q = num_digits; q < 32; ++q)
48607 if(arg&(1<<q))
48608 num_digits = q+1;
48609 for(int q = 0; q < num_digits; ++q)
48610 {
48611 argbuf[q] = (arg&(1<<(num_digits-q-1)))
48612 ? '1' : '0';
48613 }
48614 ret = argbuf;
48615 return ret.c_str();
48616 }
48617 case 'a': //array
48618 {
48619 if(arg)
48620 {
48621 if(!is_valid_format(format[1]))
48622 {
48623 Z_scripterrlog("Format '%%a%c' is invalid!\n",format[1]);
48624 break;
48625 }
48626 ArrayManager am(arg/10000);
48627 ret = am.asString([&](int32_t val)
48628 {
48629 return zs_formatter(format+1, val, mindig, flags);
48630 }, 214748);
48631 }
48632 else ret = "{ NULL }";
48633 return ret.c_str();
48634 }
48635 default:
48636 {
48637 Z_scripterrlog("Error: '%%%c' is not a valid printf argument.\n",format[0]);
48638 return ret.c_str();
48639 }
48640 }
48641
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 28927 times.
✗ Branch 2 not taken.
28927 }
48642 Z_scripterrlog("Error: No format parameter given for zs_formatter\n");
48643 return ret.c_str();
48644 28927 }
48645
48646 5379 static int32_t zspr_varg_getter(int32_t,int32_t next_arg)
48647 {
48648 5379 return zs_vargs.at(next_arg);
48649 }
48650 23548 static int32_t zspr_stack_getter(int32_t num_args, int32_t next_arg)
48651 {
48652 23548 return SH::read_stack(((ri->sp + num_args) - 1) - next_arg);
48653 }
48654 15254 string zs_sprintf(char const* format, int32_t num_args, std::function<int32_t(int32_t,int32_t)> arg_getter)
48655 {
48656 15254 int32_t next_arg = 0;
48657 15254 bool is_old_args = get_qr(qr_OLD_PRINTF_ARGS);
48658 15254 ostringstream oss;
48659
2/2
✓ Branch 0 taken 11618 times.
✓ Branch 1 taken 32563 times.
44181 while(format[0] != '\0')
48660 {
48661 32563 int32_t arg_val = 0;
48662
2/2
✓ Branch 0 taken 28927 times.
✓ Branch 1 taken 3636 times.
32563 if(next_arg < num_args)
48663 {
48664
1/2
✓ Branch 0 taken 28927 times.
✗ Branch 1 not taken.
28927 arg_val = arg_getter(num_args,next_arg);
48665 28927 }
48666
2/4
✓ Branch 0 taken 3636 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3636 times.
3636 else if(get_qr(qr_PRINTF_NO_0FILL))
48667 {
48668 oss << format;
48669 return oss.str();
48670 }
48671 32563 char buf[256] = {0};
48672
2/2
✓ Branch 0 taken 28927 times.
✓ Branch 1 taken 87960 times.
116887 for ( int32_t q = 0; q < 256; ++q )
48673 {
48674
2/2
✓ Branch 0 taken 3636 times.
✓ Branch 1 taken 84324 times.
87960 if(format[0] == '\0') //done
48675 {
48676
1/2
✓ Branch 0 taken 3636 times.
✗ Branch 1 not taken.
3636 oss << buf;
48677
1/2
✓ Branch 0 taken 3636 times.
✗ Branch 1 not taken.
3636 return oss.str();
48678 }
48679
2/2
✓ Branch 0 taken 29242 times.
✓ Branch 1 taken 55082 times.
84324 else if(format[0] == '%')
48680 {
48681 29242 ++format;
48682 29242 int32_t min_digits = 0;
48683 29242 dword formatter_flags = 0;
48684
5/6
✓ Branch 0 taken 28927 times.
✓ Branch 1 taken 315 times.
✓ Branch 2 taken 1402 times.
✓ Branch 3 taken 27525 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1402 times.
29242 if(format[0] >= '0' && format[0] <= '9' && !is_old_args)
48685 {
48686 1402 char argbuf[4] = {0};
48687 1402 int32_t q = 0;
48688
1/2
✓ Branch 0 taken 1402 times.
✗ Branch 1 not taken.
1402 if(format[0] == '0') //Leading 0 means to 0-fill, and gets eaten
48689 1402 formatter_flags |= FORMATTER_FLAG_0FILL;
48690 else --format; //else don't eat
48691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2804 times.
2804 while(q < 4)
48692 {
48693 2804 ++format;
48694 2804 char c = format[0];
48695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2804 times.
2804 if(c == '\0')
48696 {
48697 Z_scripterrlog("Cannot use minimum digits flag with no argument\n");
48698 oss << buf;
48699 return oss.str();
48700 }
48701
3/4
✓ Branch 0 taken 2804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1402 times.
✓ Branch 3 taken 1402 times.
2804 if(c >= '0' && c <= '9')
48702 1402 argbuf[q++] = c;
48703 else
48704 {
48705 1402 --format;
48706 1402 break;
48707 }
48708 }
48709 1402 ++format;
48710 1402 min_digits = atoi(argbuf);
48711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1402 times.
1402 if(!min_digits)
48712 {
48713 Z_scripterrlog("Error formatting string: Invalid number '%s'\n", argbuf);
48714 }
48715 1402 }
48716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29242 times.
29242 bool bin = (format[0] == 'b' || format[0] == 'B');
48717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29242 times.
29242 bool hex = (format[0] == 'x' || format[0] == 'X');
48718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29242 times.
29242 if(bin)
48719 {
48720 if(min_digits > 32)
48721 {
48722 Z_scripterrlog("Min digits argument cannot be larger than 32!"
48723 " Value will be truncated to 32.");
48724 min_digits = 32;
48725 }
48726 }
48727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29242 times.
29242 else if(min_digits > 10)
48728 {
48729 Z_scripterrlog("Min digits argument cannot be larger than 10!"
48730 " Value will be truncated to 10.");
48731 min_digits = 10;
48732 }
48733
48734 29242 bool tempbool = false;
48735
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 28927 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 315 times.
29242 switch( format[0] )
48736 {
48737 case 'd':
48738 case 'f':
48739 case 'i': case 'p':
48740 case 'l':
48741 case 's':
48742 case 'c':
48743 case 'x': case 'X':
48744 case 'b': case 'B':
48745 {
48746 28927 ++next_arg;
48747
3/6
✓ Branch 0 taken 28927 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28927 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 28927 times.
✗ Branch 5 not taken.
28927 oss << buf << zs_formatter(format,arg_val,min_digits,formatter_flags);
48748 28927 q = 300; //break main loop
48749 28927 break;
48750 }
48751 case 'a': //array print
48752 {
48753 ++next_arg;
48754 oss << buf << zs_formatter(format,arg_val,min_digits,formatter_flags);
48755 while(format[0] == 'a')
48756 {
48757 if(is_valid_format(format[1]))
48758 ++format;
48759 else break;
48760 }
48761 q = 300; //break main loop
48762 break;
48763 }
48764 case '%':
48765 {
48766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 if(min_digits)
48767 Z_scripterrlog("Cannot use minimum digits flag for '%%%%'\n");
48768 315 buf[q] = '%';
48769 315 break;
48770 }
48771 default:
48772 {
48773 if(is_old_args)
48774 buf[q] = format[0];
48775 else
48776 {
48777 Z_scripterrlog("Error: '%%%c' is not a valid printf argument.\n",format[0]);
48778 }
48779 break;
48780 }
48781 }
48782 29242 ++format;
48783 29242 }
48784 else
48785 {
48786 55082 buf[q] = format[0];
48787 55082 ++format;
48788 }
48789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84324 times.
84324 if(q == 255)
48790 {
48791 oss << buf;
48792 break;
48793 }
48794 84324 }
48795 }
48796
1/2
✓ Branch 0 taken 11618 times.
✗ Branch 1 not taken.
11618 return oss.str();
48797 15254 }
48798
48799 3609 void FFScript::do_printf(const bool v, const bool varg)
48800 {
48801 int32_t num_args, format_arrayptr;
48802
2/2
✓ Branch 0 taken 3322 times.
✓ Branch 1 taken 287 times.
3609 if(varg)
48803 {
48804 3322 num_args = zs_vargs.size();
48805 3322 format_arrayptr = SH::read_stack(ri->sp) / 10000;
48806 3322 }
48807 else
48808 {
48809 287 num_args = SH::get_arg(sarg1, v) / 10000;
48810 287 format_arrayptr = SH::read_stack(ri->sp + num_args) / 10000;
48811 }
48812 3609 ArrayManager fmt_am(format_arrayptr);
48813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3609 times.
3609 if(!fmt_am.invalid())
48814 {
48815 3609 string formatstr;
48816
1/2
✓ Branch 0 taken 3609 times.
✗ Branch 1 not taken.
3609 ArrayH::getString(format_arrayptr, formatstr, MAX_ZC_ARRAY_SIZE);
48817
48818
4/6
✓ Branch 0 taken 3322 times.
✓ Branch 1 taken 287 times.
✓ Branch 2 taken 3609 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3609 times.
3609 traceStr(zs_sprintf(formatstr.c_str(), num_args, varg ? zspr_varg_getter : zspr_stack_getter));
48819 3609 }
48820
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 3322 times.
3609 if(varg)
48821 3322 zs_vargs.clear();
48822 3609 }
48823 11645 void FFScript::do_sprintf(const bool v, const bool varg)
48824 {
48825 int32_t num_args, dest_arrayptr, format_arrayptr;
48826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11645 times.
11645 if(varg)
48827 {
48828 num_args = zs_vargs.size();
48829 dest_arrayptr = SH::read_stack(ri->sp + 1) / 10000;
48830 format_arrayptr = SH::read_stack(ri->sp) / 10000;
48831 }
48832 else
48833 {
48834 11645 num_args = SH::get_arg(sarg1, v) / 10000;
48835 11645 dest_arrayptr = SH::read_stack(ri->sp + num_args + 1) / 10000;
48836 11645 format_arrayptr = SH::read_stack(ri->sp + num_args) / 10000;
48837 }
48838 11645 ArrayManager fmt_am(format_arrayptr);
48839 11645 ArrayManager dst_am(dest_arrayptr);
48840
2/4
✓ Branch 0 taken 11645 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11645 times.
11645 if(fmt_am.invalid() || dst_am.invalid())
48841 ri->d[rEXP1] = 0;
48842 else
48843 {
48844 11645 string formatstr;
48845
1/2
✓ Branch 0 taken 11645 times.
✗ Branch 1 not taken.
11645 ArrayH::getString(format_arrayptr, formatstr, MAX_ZC_ARRAY_SIZE);
48846
48847
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11645 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11645 times.
11645 string output = zs_sprintf(formatstr.c_str(), num_args, varg ? zspr_varg_getter : zspr_stack_getter);
48848
2/4
✓ Branch 0 taken 11645 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11645 times.
11645 if(ArrayH::setArray(dest_arrayptr, output, true) == SH::_Overflow)
48849 {
48850 Z_scripterrlog("Dest string supplied to 'sprintf()' not large enough and cannot be resized\n");
48851 ri->d[rEXP1] = ArrayH::strlen(dest_arrayptr);
48852 }
48853 11645 else ri->d[rEXP1] = output.size();
48854 11645 }
48855
1/2
✓ Branch 0 taken 11645 times.
✗ Branch 1 not taken.
11645 if(varg)
48856 zs_vargs.clear();
48857 11645 }
48858 void FFScript::do_printfarr()
48859 {
48860 int32_t format_arrayptr = SH::read_stack(ri->sp + 1) / 10000,
48861 args_arrayptr = SH::read_stack(ri->sp + 0) / 10000;
48862 ArrayManager fmt_am(format_arrayptr);
48863 ArrayManager arg_am(args_arrayptr);
48864 if(!(fmt_am.invalid() || arg_am.invalid()))
48865 {
48866 auto num_args = arg_am.size();
48867 string formatstr;
48868 ArrayH::getString(format_arrayptr, formatstr, MAX_ZC_ARRAY_SIZE);
48869
48870 traceStr(zs_sprintf(formatstr.c_str(), num_args,
48871 [&](int32_t,int32_t next_arg)
48872 {
48873 return arg_am.get(next_arg);
48874 }));
48875 }
48876 }
48877 void FFScript::do_sprintfarr()
48878 {
48879 int32_t dest_arrayptr = SH::read_stack(ri->sp + 2) / 10000,
48880 format_arrayptr = SH::read_stack(ri->sp + 1) / 10000,
48881 args_arrayptr = SH::read_stack(ri->sp + 0) / 10000;
48882 ArrayManager fmt_am(format_arrayptr);
48883 ArrayManager arg_am(args_arrayptr);
48884 ArrayManager dst_am(dest_arrayptr);
48885 if(fmt_am.invalid() || arg_am.invalid() || dst_am.invalid())
48886 ri->d[rEXP1] = 0;
48887 else
48888 {
48889 auto num_args = arg_am.size();
48890 string formatstr;
48891 ArrayH::getString(format_arrayptr, formatstr, MAX_ZC_ARRAY_SIZE);
48892
48893 string output = zs_sprintf(formatstr.c_str(), num_args,
48894 [&](int32_t,int32_t next_arg)
48895 {
48896 return arg_am.get(next_arg);
48897 });
48898
48899 if(ArrayH::setArray(dest_arrayptr, output, true) == SH::_Overflow)
48900 {
48901 Z_scripterrlog("Dest string supplied to 'sprintfa()' not large enough and cannot be resized\n");
48902 ri->d[rEXP1] = ArrayH::strlen(dest_arrayptr);
48903 }
48904 else ri->d[rEXP1] = output.size();
48905 }
48906 }
48907 27143 void FFScript::do_varg_max()
48908 {
48909 27143 int32_t num_args = zs_vargs.size();
48910 27143 int32_t val = 0;
48911
1/2
✓ Branch 0 taken 27143 times.
✗ Branch 1 not taken.
27143 if (num_args > 0)
48912 27143 val = zs_vargs.at(0);
48913
2/2
✓ Branch 0 taken 27143 times.
✓ Branch 1 taken 27143 times.
54286 for(auto q = 1; q < num_args; ++q)
48914 {
48915 27143 int32_t tval = zs_vargs.at(q);
48916
2/2
✓ Branch 0 taken 9172 times.
✓ Branch 1 taken 17971 times.
27143 if(tval > val) val = tval;
48917 27143 }
48918 27143 zs_vargs.clear();
48919 27143 ri->d[rEXP1] = val;
48920 27143 }
48921 72 void FFScript::do_varg_min()
48922 {
48923 72 int32_t num_args = zs_vargs.size();
48924 72 int32_t val = 0;
48925
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if (num_args > 0)
48926 72 val = zs_vargs.at(0);
48927
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 72 times.
144 for(auto q = 1; q < num_args; ++q)
48928 {
48929 72 int32_t tval = zs_vargs.at(q);
48930
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if(tval < val) val = tval;
48931 72 }
48932 72 zs_vargs.clear();
48933 72 ri->d[rEXP1] = val;
48934 72 }
48935 void FFScript::do_varg_choose()
48936 {
48937 int32_t num_args = zs_vargs.size();
48938 int32_t val = 0;
48939 if(num_args > 0)
48940 {
48941 int32_t choice = zc_rand(num_args-1);
48942 val = zs_vargs.at(choice);
48943 }
48944 zs_vargs.clear();
48945 ri->d[rEXP1] = val;
48946 }
48947 void FFScript::do_varg_makearray(ScriptType type, const uint32_t UID)
48948 {
48949 size_t num_args = zs_vargs.size();
48950 //
48951 dword ptrval;
48952 for(ptrval = 1; localRAM[ptrval].Valid(); ptrval++) ;
48953
48954 if(ptrval >= NUM_ZSCRIPT_ARRAYS)
48955 {
48956 Z_scripterrlog("%d local arrays already in use, no more can be allocated\n", NUM_ZSCRIPT_ARRAYS-1);
48957 ptrval = 0;
48958 }
48959 else
48960 {
48961 ZScriptArray &a = localRAM[ptrval]; //marginally faster for large arrays if we use a reference
48962
48963 a.Resize(num_args);
48964 a.setValid(true);
48965
48966 for(size_t j = 0; j < num_args; ++j)
48967 a[j] = zs_vargs[j]; //initialize array
48968
48969 arrayOwner[ptrval].reown(type, UID);
48970 }
48971 //
48972 zs_vargs.clear();
48973 ri->d[rEXP1] = ptrval*10000;
48974 }
48975
48976 void FFScript::do_breakpoint()
48977 {
48978 int32_t arrayptr = get_register(sarg1) / 10000;
48979 string str;
48980 if(arrayptr && sarg1 != NUL)
48981 {
48982 ArrayH::getString(arrayptr, str, 512);
48983 str = "Breakpoint: " + str + "\n";
48984 }
48985 else str = "Breakpoint\n";
48986 TraceScriptIDs();
48987 al_trace("%s", str.c_str());
48988
48989 if ( zscript_debugger )
48990 {
48991 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_RED |
48992 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),str.c_str());
48993 }
48994 if( zasm_debugger )
48995 {
48996 FFCore.zasm_break_mode = ZASM_BREAK_HALT; //Halt ZASM debugger; break execution
48997 coloured_console.safeprint((CConsoleLoggerEx::COLOR_RED |
48998 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),str.c_str());
48999 }
49000 }
49001
49002 void FFScript::do_tracenl()
49003 {
49004 safe_al_trace("\n");
49005
49006 if ( zscript_debugger )
49007 {
49008 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
49009 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),"\n");
49010 }
49011 }
49012
49013
49014 36998 void FFScript::TraceScriptIDs(bool zasm_console)
49015 {
49016 if(DEVTIMESTAMP)
49017 {
49018 if(!zasm_debugger && zasm_console) return;
49019 CConsoleLoggerEx console = (zasm_console ? coloured_console : zscript_coloured_console);
49020 bool cond = (zasm_console ? zasm_debugger : zscript_debugger);
49021
49022 char buf[256] = {0};
49023 //Calculate timestamp
49024 struct tm * tm_struct;
49025 time_t sysRTC;
49026 time (&sysRTC);
49027 tm_struct = localtime (&sysRTC);
49028
49029 sprintf(buf, "[%d:%d:%d] ", tm_struct->tm_hour, tm_struct->tm_min, tm_struct->tm_sec);
49030 //
49031
49032 al_trace("%s", buf);
49033 if ( cond ) {console.safeprint((CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
49034 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),buf); }
49035 }
49036
2/2
✓ Branch 0 taken 33593 times.
✓ Branch 1 taken 3405 times.
36998 if(get_qr(qr_TRACESCRIPTIDS) || DEVLOGGING )
49037 {
49038
2/4
✓ Branch 0 taken 3405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3405 times.
✗ Branch 3 not taken.
3405 if(!zasm_debugger && zasm_console) return;
49039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3405 times.
3405 CConsoleLoggerEx console = (zasm_console ? coloured_console : zscript_coloured_console);
49040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3405 times.
3405 bool cond = (zasm_console ? zasm_debugger : zscript_debugger);
49041 3405 char buf[256] = {0};
49042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3405 times.
3405 if(script_funcrun)
49043 {
49044 sprintf(buf, "Destructor(%d,%s): ", ri->thiskey, destructstr?destructstr->c_str():"UNKNOWN");
49045 }
49046
4/18
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1297 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2058 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
3405 else switch(curScriptType)
49047 {
49048 case ScriptType::Global:
49049 {
49050 switch(curScriptNum)
49051 {
49052 case GLOBAL_SCRIPT_INIT:
49053 sprintf(buf, "Global Init(%s): ", globalmap[curScriptNum].scriptname.c_str());
49054 break;
49055 case GLOBAL_SCRIPT_GAME:
49056 sprintf(buf, "Global Active(%s): ", globalmap[curScriptNum].scriptname.c_str());
49057 break;
49058 case GLOBAL_SCRIPT_END:
49059 sprintf(buf, "Global Exit(%s): ", globalmap[curScriptNum].scriptname.c_str());
49060 break;
49061 case GLOBAL_SCRIPT_ONSAVELOAD:
49062 sprintf(buf, "Global SaveLoad(%s): ", globalmap[curScriptNum].scriptname.c_str());
49063 break;
49064 case GLOBAL_SCRIPT_ONLAUNCH:
49065 sprintf(buf, "Global Launch(%s): ", globalmap[curScriptNum].scriptname.c_str());
49066 break;
49067 case GLOBAL_SCRIPT_ONCONTGAME:
49068 sprintf(buf, "Global ContGame(%s): ", globalmap[curScriptNum].scriptname.c_str());
49069 break;
49070 case GLOBAL_SCRIPT_F6:
49071 sprintf(buf, "Global F6Menu(%s): ", globalmap[curScriptNum].scriptname.c_str());
49072 break;
49073 case GLOBAL_SCRIPT_ONSAVE:
49074 sprintf(buf, "Global Save(%s): ", globalmap[curScriptNum].scriptname.c_str());
49075 break;
49076 }
49077 break;
49078 }
49079
49080 case ScriptType::Player:
49081 {
49082 switch(curScriptNum)
49083 {
49084 case SCRIPT_PLAYER_INIT:
49085 sprintf(buf, "Player Init(%s): ", playermap[curScriptNum-1].scriptname.c_str());
49086 break;
49087 case SCRIPT_PLAYER_ACTIVE:
49088 sprintf(buf, "Player Active(%s): ", playermap[curScriptNum-1].scriptname.c_str());
49089 break;
49090 case SCRIPT_PLAYER_DEATH:
49091 sprintf(buf, "Player Death(%s): ", playermap[curScriptNum-1].scriptname.c_str());
49092 break;
49093 case SCRIPT_PLAYER_WIN:
49094 sprintf(buf, "Player Win(%s): ", playermap[curScriptNum-1].scriptname.c_str());
49095 break;
49096 }
49097 break;
49098 }
49099
49100 case ScriptType::Lwpn:
49101
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 sprintf(buf, "LWeapon(%u, %s): ", curScriptNum,lwpnmap[curScriptNum-1].scriptname.c_str());
49102 48 break;
49103
49104 case ScriptType::Ewpn:
49105 sprintf(buf, "EWeapon(%u, %s): ", curScriptNum,ewpnmap[curScriptNum-1].scriptname.c_str());
49106 break;
49107
49108 case ScriptType::NPC:
49109 sprintf(buf, "NPC(%u, %s): ", curScriptNum,npcmap[curScriptNum-1].scriptname.c_str());
49110 break;
49111
49112 case ScriptType::FFC:
49113
1/2
✓ Branch 0 taken 1297 times.
✗ Branch 1 not taken.
1297 sprintf(buf, "FFC(%u, %s): ", curScriptNum,ffcmap[curScriptNum-1].scriptname.c_str());
49114 1297 break;
49115
49116 case ScriptType::Item:
49117 sprintf(buf, "Item(%u, %s): ", curScriptNum,itemmap[curScriptNum-1].scriptname.c_str());
49118 break;
49119
49120 case ScriptType::OnMap:
49121 sprintf(buf, "DMapMap(%u, %s): ", curScriptNum,dmapmap[curScriptNum-1].scriptname.c_str());
49122 break;
49123 case ScriptType::ScriptedActiveSubscreen:
49124 sprintf(buf, "DMapASub(%u, %s): ", curScriptNum,dmapmap[curScriptNum-1].scriptname.c_str());
49125 break;
49126 case ScriptType::ScriptedPassiveSubscreen:
49127
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 sprintf(buf, "DMapPSub(%u, %s): ", curScriptNum,dmapmap[curScriptNum-1].scriptname.c_str());
49128 2 break;
49129 case ScriptType::DMap:
49130
1/2
✓ Branch 0 taken 2058 times.
✗ Branch 1 not taken.
2058 sprintf(buf, "DMap(%u, %s): ", curScriptNum,dmapmap[curScriptNum-1].scriptname.c_str());
49131 2058 break;
49132
49133 case ScriptType::ItemSprite:
49134 sprintf(buf, "ItemSprite(%u, %s): ", curScriptNum,itemspritemap[curScriptNum-1].scriptname.c_str());
49135 break;
49136
49137 case ScriptType::Screen:
49138 sprintf(buf, "Screen(%u, %s): ", curScriptNum,screenmap[curScriptNum-1].scriptname.c_str());
49139 break;
49140
49141 case ScriptType::Combo:
49142 sprintf(buf, "Combo(%u, %s): ", curScriptNum,comboscriptmap[curScriptNum-1].scriptname.c_str());
49143 break;
49144
49145 case ScriptType::Generic:
49146 sprintf(buf, "Generic(%u, %s): ", curScriptNum,genericmap[curScriptNum-1].scriptname.c_str());
49147 break;
49148
49149 case ScriptType::GenericFrozen:
49150 sprintf(buf, "GenericFRZ(%u, %s): ", curScriptNum,genericmap[curScriptNum-1].scriptname.c_str());
49151 break;
49152
49153 case ScriptType::EngineSubscreen:
49154 sprintf(buf, "Subscreen(%u, %s): ", curScriptNum,subscreenmap[curScriptNum-1].scriptname.c_str());
49155 break;
49156 }
49157
49158
1/2
✓ Branch 0 taken 3405 times.
✗ Branch 1 not taken.
3405 al_trace("%s", buf);
49159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3405 times.
3405 if ( cond )
49160 console.safeprint((CConsoleLoggerEx::COLOR_GREEN|CConsoleLoggerEx::COLOR_INTENSITY|
49161 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),buf);
49162 3405 }
49163 36998 }
49164
49165 2 void FFScript::do_cleartrace()
49166 {
49167 2 zc_trace_clear();
49168 2 clearConsole();
49169 2 }
49170
49171 1 string inttobase(word base, int32_t x, word mindigits)
49172 {
49173 static const char coeff[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
49174
49175 1 string s2;
49176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 word digits = zc_max(mindigits - 1, word(floor(log(double(x)) / log(double(base)))));
49177
49178
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 for(int32_t i = digits; i >= 0; i--)
49179 {
49180
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 s2 += coeff[word(floor(x / pow(double(base), i))) % base];
49181 1 }
49182
49183 1 return s2;
49184
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 }
49185
49186 1 void FFScript::do_tracetobase()
49187 {
49188 1 int32_t x = SH::read_stack(ri->sp + 2) / 10000;
49189 1 uint32_t base = vbound(SH::read_stack(ri->sp + 1) / 10000, 2, 36);
49190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 uint32_t mindigits = zc_max(1, SH::read_stack(ri->sp) / 10000);
49191
49192
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 string s2 = x < 0 ? "-": "";
49193
49194
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 switch(base)
49195 {
49196 case 8:
49197 s2 += '0';
49198 break;
49199
49200 case 16:
49201 s2 += "0x";
49202 break;
49203 }
49204
49205
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 s2 += inttobase(base, int32_t(fabs(double(x))), mindigits);
49206
49207
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 switch(base)
49208 {
49209 case 8:
49210 case 10:
49211 case 16:
49212 1 break;
49213
49214 case 2:
49215 s2 += 'b';
49216 break;
49217
49218 default:
49219 std::stringstream ss;
49220 ss << " (Base " << base << ')';
49221 s2 += ss.str();
49222 break;
49223 }
49224
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 TraceScriptIDs();
49225
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 s2 += "\n";
49226
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 al_trace("%s", s2.c_str());
49227
49228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( zscript_debugger )
49229 {
49230 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
49231 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),s2.c_str());
49232 }
49233 1 }
49234
49235 //SRAM Functions
49236 void FFScript::write_dmaps(PACKFILE *f, int32_t vers_id)
49237 {
49238 word dmap_count=count_dmaps();
49239
49240 dmap_count=zc_min(dmap_count, 512);
49241 dmap_count=zc_min(dmap_count, MAXDMAPS-0);
49242
49243 //finally... section data
49244 if(!p_iputw(dmap_count,f))
49245 {
49246 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",5);
49247 }
49248
49249
49250 for(int32_t i=0; i<dmap_count; i++)
49251 {
49252 if(!p_putc(DMaps[i].map,f))
49253 {
49254 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",6);
49255 }
49256
49257 if(!p_iputw(DMaps[i].level,f))
49258 {
49259 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",7);
49260 }
49261
49262 if(!p_putc(DMaps[i].xoff,f))
49263 {
49264 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",8);
49265 }
49266
49267 if(!p_putc(DMaps[i].compass,f))
49268 {
49269 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",9);
49270 }
49271
49272 if(!p_iputw(DMaps[i].color,f))
49273 {
49274 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",10);
49275 }
49276
49277 if(!p_putc(DMaps[i].midi,f))
49278 {
49279 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",11);
49280 }
49281
49282 if(!p_putc(DMaps[i].cont,f))
49283 {
49284 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",12);
49285 }
49286
49287 if(!p_putc(DMaps[i].type,f))
49288 {
49289 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",13);
49290 }
49291
49292 for(int32_t j=0; j<8; j++)
49293 {
49294 if(!p_putc(DMaps[i].grid[j],f))
49295 {
49296 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",14);
49297 }
49298 }
49299
49300 //16
49301 if(!pfwrite(&DMaps[i].name,sizeof(DMaps[0].name),f))
49302 {
49303 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",15);
49304 }
49305
49306 if(!pfwrite(&DMaps[i].title,sizeof(DMaps[0].title),f))
49307 {
49308 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",16);
49309 }
49310
49311 if(!pfwrite(&DMaps[i].intro,sizeof(DMaps[0].intro),f))
49312 {
49313 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",17);
49314 }
49315
49316 if(!p_iputl(DMaps[i].minimap_1_tile,f))
49317 {
49318 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",18);
49319 }
49320
49321 if(!p_putc(DMaps[i].minimap_1_cset,f))
49322 {
49323 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",19);
49324 }
49325
49326 if(!p_iputl(DMaps[i].minimap_2_tile,f))
49327 {
49328 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",20);
49329 }
49330
49331 if(!p_putc(DMaps[i].minimap_2_cset,f))
49332 {
49333 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",21);
49334 }
49335
49336 if(!p_iputl(DMaps[i].largemap_1_tile,f))
49337 {
49338 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",22);
49339 }
49340
49341 if(!p_putc(DMaps[i].largemap_1_cset,f))
49342 {
49343 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",23);
49344 }
49345
49346 if(!p_iputl(DMaps[i].largemap_2_tile,f))
49347 {
49348 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",24);
49349 }
49350
49351 if(!p_putc(DMaps[i].largemap_2_cset,f))
49352 {
49353 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",25);
49354 }
49355
49356 if(!pfwrite(&DMaps[i].tmusic,sizeof(DMaps[0].tmusic),f))
49357 {
49358 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",26);
49359 }
49360
49361 if(!p_putc(DMaps[i].tmusictrack,f))
49362 {
49363 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",25);
49364 }
49365
49366 if(!p_putc(DMaps[i].active_subscreen,f))
49367 {
49368 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",26);
49369 }
49370
49371 if(!p_putc(DMaps[i].passive_subscreen,f))
49372 {
49373 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",27);
49374 }
49375
49376 byte disabled[32];
49377 memset(disabled,0,32);
49378
49379 for(int32_t j=0; j<MAXITEMS; j++)
49380 {
49381 if(DMaps[i].disableditems[j])
49382 {
49383 disabled[j/8] |= (1 << (j%8));
49384 }
49385 }
49386
49387 if(!pfwrite(disabled,32,f))
49388 {
49389 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",28);
49390 }
49391
49392 if(!p_iputl(DMaps[i].flags,f))
49393 {
49394 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",29);
49395 }
49396 if(!p_putc(DMaps[i].sideview,f))
49397 {
49398 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",30);
49399 }
49400 if(!p_iputw(DMaps[i].script,f))
49401 {
49402 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",31);
49403 }
49404 for ( int32_t q = 0; q < 8; q++ )
49405 {
49406 if(!p_iputl(DMaps[i].initD[q],f))
49407 {
49408 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",32);
49409 }
49410
49411 }
49412 for ( int32_t q = 0; q < 8; q++ )
49413 {
49414 for ( int32_t w = 0; w < 65; w++ )
49415 {
49416 if (!p_putc(DMaps[i].initD_label[q][w],f))
49417 {
49418 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",33);
49419 }
49420 }
49421 }
49422 }
49423 }
49424 void FFScript::read_dmaps(PACKFILE *f, int32_t vers_id)
49425 {
49426 word dmap_count=count_dmaps();
49427
49428 dmap_count=zc_min(dmap_count, 512);
49429 dmap_count=zc_min(dmap_count, MAXDMAPS-0);
49430
49431 //finally... section data
49432 if(!p_igetw(&dmap_count,f))
49433 {
49434 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",5);
49435 }
49436
49437
49438 for(int32_t i=0; i<dmap_count; i++)
49439 {
49440 if(!p_getc(&DMaps[i].map,f))
49441 {
49442 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",6);
49443 }
49444
49445 if(!p_igetw(&DMaps[i].level,f))
49446 {
49447 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",7);
49448 }
49449
49450 if(!p_getc(&DMaps[i].xoff,f))
49451 {
49452 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",8);
49453 }
49454
49455 if(!p_getc(&DMaps[i].compass,f))
49456 {
49457 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",9);
49458 }
49459
49460 if(!p_igetw(&DMaps[i].color,f))
49461 {
49462 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",10);
49463 }
49464
49465 if(!p_getc(&DMaps[i].midi,f))
49466 {
49467 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",11);
49468 }
49469
49470 if(!p_getc(&DMaps[i].cont,f))
49471 {
49472 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",12);
49473 }
49474
49475 if(!p_getc(&DMaps[i].type,f))
49476 {
49477 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",13);
49478 }
49479
49480 for(int32_t j=0; j<8; j++)
49481 {
49482 if(!p_getc(&DMaps[i].grid[j],f))
49483 {
49484 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",14);
49485 }
49486 }
49487
49488 //16
49489 if(!pfread((&DMaps[i].name),sizeof(DMaps[0].name),f))
49490 {
49491 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",15);
49492 }
49493
49494 if(!pfread((&DMaps[i].title),sizeof(DMaps[0].title),f))
49495 {
49496 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",16);
49497 }
49498
49499 if(!pfread((&DMaps[i].intro),sizeof(DMaps[0].intro),f))
49500 {
49501 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",17);
49502 }
49503
49504 if(!p_igetl(&DMaps[i].minimap_1_tile,f))
49505 {
49506 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",18);
49507 }
49508
49509 if(!p_getc(&DMaps[i].minimap_1_cset,f))
49510 {
49511 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",19);
49512 }
49513
49514 if(!p_igetl(&DMaps[i].minimap_2_tile,f))
49515 {
49516 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",20);
49517 }
49518
49519 if(!p_getc(&DMaps[i].minimap_2_cset,f))
49520 {
49521 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",21);
49522 }
49523
49524 if(!p_igetl(&DMaps[i].largemap_1_tile,f))
49525 {
49526 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",22);
49527 }
49528
49529 if(!p_getc(&DMaps[i].largemap_1_cset,f))
49530 {
49531 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",23);
49532 }
49533
49534 if(!p_igetl(&DMaps[i].largemap_2_tile,f))
49535 {
49536 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",24);
49537 }
49538
49539 if(!p_getc(&DMaps[i].largemap_2_cset,f))
49540 {
49541 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",25);
49542 }
49543
49544 if(!pfread((&DMaps[i].tmusic),sizeof(DMaps[0].tmusic),f))
49545 {
49546 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",26);
49547 }
49548
49549 if(!p_getc(&DMaps[i].tmusictrack,f))
49550 {
49551 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",25);
49552 }
49553
49554 if(!p_getc(&DMaps[i].active_subscreen,f))
49555 {
49556 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",26);
49557 }
49558
49559 if(!p_getc(&DMaps[i].passive_subscreen,f))
49560 {
49561 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",27);
49562 }
49563
49564 byte disabled[32];
49565 memset(disabled,0,32);
49566
49567 for(int32_t j=0; j<MAXITEMS; j++)
49568 {
49569 if(&DMaps[i].disableditems[j])
49570 {
49571 disabled[j/8] |= (1 << (j%8));
49572 }
49573 }
49574
49575 if(!pfread(disabled,32,f))
49576 {
49577 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",28);
49578 }
49579
49580 if(!p_igetl(&DMaps[i].flags,f))
49581 {
49582 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",29);
49583 }
49584 if(!p_getc(&DMaps[i].sideview,f))
49585 {
49586 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",30);
49587 }
49588 if(!p_igetw(&DMaps[i].script,f))
49589 {
49590 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",31);
49591 }
49592 for ( int32_t q = 0; q < 8; q++ )
49593 {
49594 if(!p_igetl(&DMaps[i].initD[q],f))
49595 {
49596 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",32);
49597 }
49598
49599 }
49600 for ( int32_t q = 0; q < 8; q++ )
49601 {
49602 for ( int32_t w = 0; w < 65; w++ )
49603 {
49604 if (!p_getc(&DMaps[i].initD_label[q][w],f))
49605 {
49606 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",33);
49607 }
49608 }
49609 }
49610 }
49611 }
49612
49613
49614
49615 void FFScript::read_combos(PACKFILE *f, int32_t version_id)
49616 {
49617
49618 word combos_used = 0;
49619
49620 if(!p_igetw(&combos_used,f))
49621 {
49622 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",5);
49623 }
49624
49625 for(int32_t i=0; i<combos_used; i++)
49626 {
49627 if(!p_igetl(&combobuf[i].tile,f))
49628 {
49629 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",6);
49630 }
49631
49632 if(!p_getc(&combobuf[i].flip,f))
49633 {
49634 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",7);
49635 }
49636
49637 if(!p_getc(&combobuf[i].walk,f))
49638 {
49639 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",8);
49640 }
49641
49642 if(!p_getc(&combobuf[i].type,f))
49643 {
49644 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",9);
49645 }
49646
49647 if(!p_getc(&combobuf[i].csets,f))
49648 {
49649 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",10);
49650 }
49651
49652 if(!p_getc(&combobuf[i].frames,f))
49653 {
49654 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",11);
49655 }
49656
49657 if(!p_getc(&combobuf[i].speed,f))
49658 {
49659 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",12);
49660 }
49661
49662 if(!p_igetw(&combobuf[i].nextcombo,f))
49663 {
49664 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",13);
49665 }
49666
49667 if(!p_getc(&combobuf[i].nextcset,f))
49668 {
49669 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",14);
49670 }
49671
49672 if(!p_getc(&combobuf[i].flag,f))
49673 {
49674 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",15);
49675 }
49676
49677 if(!p_getc(&combobuf[i].skipanim,f))
49678 {
49679 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",16);
49680 }
49681
49682 if(!p_igetw(&combobuf[i].nexttimer,f))
49683 {
49684 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",17);
49685 }
49686
49687 if(!p_getc(&combobuf[i].skipanimy,f))
49688 {
49689 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",18);
49690 }
49691
49692 if(!p_getc(&combobuf[i].animflags,f))
49693 {
49694 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",19);
49695 }
49696
49697 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
49698 {
49699 if(!p_igetl(&combobuf[i].attributes[q],f))
49700 {
49701 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",20);
49702 }
49703 }
49704 if(!p_igetl(&combobuf[i].usrflags,f))
49705 {
49706 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",21);
49707 }
49708 for ( int32_t q = 0; q < 6; q++ )
49709 {
49710 if(!p_igetl(&combobuf[i].triggerflags[q],f))
49711 {
49712 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",22);
49713 }
49714 }
49715
49716 if(!p_igetl(&combobuf[i].triggerlevel,f))
49717 {
49718 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",23);
49719 }
49720 for ( int32_t q = 0; q < 11; q++ )
49721 {
49722 if(!p_getc(&combobuf[i].label[q],f))
49723 {
49724 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",24);
49725 }
49726 }
49727 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
49728 {
49729 if(!p_getc(&combobuf[i].attribytes[q],f))
49730 {
49731 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",25);
49732 }
49733 }
49734 if(!p_igetw(&combobuf[i].script,f))
49735 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",26);
49736 for ( int32_t q = 0; q < 2; q++ )
49737 {
49738 if(!p_igetl(&combobuf[i].initd[q],f))
49739 {
49740 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",27);
49741 }
49742 }
49743 if(!p_igetl(&combobuf[i].o_tile,f))
49744 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",28);
49745 if(!p_getc(&combobuf[i].cur_frame,f))
49746 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",29);
49747 if(!p_getc(&combobuf[i].aclk,f))
49748 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",30);
49749 }
49750 }
49751
49752 void FFScript::write_combos(PACKFILE *f, int32_t version_id)
49753 {
49754
49755 word combos_used = 0;
49756
49757 //finally... section data
49758 combos_used=count_combos()-0;
49759 combos_used=zc_min(combos_used, MAXCOMBOS);
49760
49761 if(!p_iputw(combos_used,f))
49762 {
49763 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",5);
49764 }
49765
49766 for(int32_t i=0; i<combos_used; i++)
49767 {
49768 if(!p_iputl(combobuf[i].tile,f))
49769 {
49770 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",6);
49771 }
49772
49773 if(!p_putc(combobuf[i].flip,f))
49774 {
49775 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",7);
49776 }
49777
49778 if(!p_putc(combobuf[i].walk,f))
49779 {
49780 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",8);
49781 }
49782
49783 if(!p_putc(combobuf[i].type,f))
49784 {
49785 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",9);
49786 }
49787
49788 if(!p_putc(combobuf[i].csets,f))
49789 {
49790 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",10);
49791 }
49792
49793 if(!p_putc(combobuf[i].frames,f))
49794 {
49795 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",11);
49796 }
49797
49798 if(!p_putc(combobuf[i].speed,f))
49799 {
49800 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",12);
49801 }
49802
49803 if(!p_iputw(combobuf[i].nextcombo,f))
49804 {
49805 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",13);
49806 }
49807
49808 if(!p_putc(combobuf[i].nextcset,f))
49809 {
49810 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",14);
49811 }
49812
49813 if(!p_putc(combobuf[i].flag,f))
49814 {
49815 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",15);
49816 }
49817
49818 if(!p_putc(combobuf[i].skipanim,f))
49819 {
49820 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",16);
49821 }
49822
49823 if(!p_iputw(combobuf[i].nexttimer,f))
49824 {
49825 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",17);
49826 }
49827
49828 if(!p_putc(combobuf[i].skipanimy,f))
49829 {
49830 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",18);
49831 }
49832
49833 if(!p_putc(combobuf[i].animflags,f))
49834 {
49835 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",19);
49836 }
49837
49838 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
49839 {
49840 if(!p_iputl(combobuf[i].attributes[q],f))
49841 {
49842 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",20);
49843 }
49844 }
49845 if(!p_iputl(combobuf[i].usrflags,f))
49846 {
49847 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",21);
49848 }
49849 for ( int32_t q = 0; q < 6; q++ )
49850 {
49851 if(!p_iputl(combobuf[i].triggerflags[q],f))
49852 {
49853 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",22);
49854 }
49855 }
49856
49857 if(!p_iputl(combobuf[i].triggerlevel,f))
49858 {
49859 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",23);
49860 }
49861 for ( int32_t q = 0; q < 11; q++ )
49862 {
49863 if(!p_putc(combobuf[i].label[q],f))
49864 {
49865 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",24);
49866 }
49867 }
49868 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
49869 {
49870 if(!p_putc(combobuf[i].attribytes[q],f))
49871 {
49872 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",25);
49873 }
49874 }
49875 if(!p_iputw(combobuf[i].script,f))
49876 {
49877 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",26);
49878 }
49879 for ( int32_t q = 0; q < 2; q++ )
49880 {
49881 if(!p_iputl(combobuf[i].initd[q],f))
49882 {
49883 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",27);
49884 }
49885 }
49886 if(!p_iputl(combobuf[i].o_tile,f))
49887 {
49888 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",28);
49889 }
49890 if(!p_putc(combobuf[i].cur_frame,f))
49891 {
49892 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",29);
49893 }
49894 if(!p_putc(combobuf[i].aclk,f))
49895 {
49896 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",30);
49897 }
49898
49899 }
49900 }
49901 void FFScript::read_weaponsprtites(PACKFILE *f, int32_t vers_id)
49902 {
49903 for(int32_t i=0; i<MAXWPNS; i++)
49904 {
49905 word oldtile = 0;
49906 if(!p_igetw(&oldtile,f))
49907 {
49908 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",6);
49909 }
49910
49911 if(!p_getc(&wpnsbuf[i].misc,f))
49912 {
49913 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",7);
49914 }
49915
49916 if(!p_getc(&wpnsbuf[i].csets,f))
49917 {
49918 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",8);
49919 }
49920
49921 if(!p_getc(&wpnsbuf[i].frames,f))
49922 {
49923 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",9);
49924 }
49925
49926 if(!p_getc(&wpnsbuf[i].speed,f))
49927 {
49928 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",10);
49929 }
49930
49931 if(!p_getc(&wpnsbuf[i].type,f))
49932 {
49933 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",11);
49934 }
49935
49936 if(!p_igetw(&wpnsbuf[i].script,f))
49937 {
49938 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",12);
49939 }
49940
49941 if(!p_igetl(&wpnsbuf[i].tile,f))
49942 {
49943 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",12);
49944 }
49945 }
49946 }
49947 void FFScript::write_weaponsprtites(PACKFILE *f, int32_t vers_id)
49948 {
49949 for(int32_t i=0; i<MAXWPNS; i++)
49950 {
49951 if(!p_iputw(wpnsbuf[i].tile,f))
49952 {
49953 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",6);
49954 }
49955
49956 if(!p_putc(wpnsbuf[i].misc,f))
49957 {
49958 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",7);
49959 }
49960
49961 if(!p_putc(wpnsbuf[i].csets,f))
49962 {
49963 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",8);
49964 }
49965
49966 if(!p_putc(wpnsbuf[i].frames,f))
49967 {
49968 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",9);
49969 }
49970
49971 if(!p_putc(wpnsbuf[i].speed,f))
49972 {
49973 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",10);
49974 }
49975
49976 if(!p_putc(wpnsbuf[i].type,f))
49977 {
49978 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",11);
49979 }
49980
49981 if(!p_iputw(wpnsbuf[i].script,f))
49982 {
49983 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",12);
49984 }
49985
49986 if(!p_iputl(wpnsbuf[i].tile,f))
49987 {
49988 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",12);
49989 }
49990 }
49991 }
49992
49993
49994 void FFScript::read_enemies(PACKFILE *f, int32_t vers_id)
49995 {
49996 if ( !f ) return;
49997 for(int32_t i=0; i<MAXGUYS; i++)
49998 {
49999 if(!p_igetl(&guysbuf[i].flags,f))
50000 {
50001 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",6);
50002 }
50003
50004 if(!p_igetl(&guysbuf[i].flags2,f))
50005 {
50006 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",7);
50007 }
50008
50009 if(!p_igetl(&guysbuf[i].tile,f))
50010 {
50011 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",8);
50012 }
50013
50014 if(!p_getc(&guysbuf[i].width,f))
50015 {
50016 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",9);
50017 }
50018
50019 if(!p_getc(&guysbuf[i].height,f))
50020 {
50021 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",10);
50022 }
50023
50024 if(!p_igetl(&guysbuf[i].s_tile,f))
50025 {
50026 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",11);
50027 }
50028
50029 if(!p_getc(&guysbuf[i].s_width,f))
50030 {
50031 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",12);
50032 }
50033
50034 if(!p_getc(&guysbuf[i].s_height,f))
50035 {
50036 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",13);
50037 }
50038
50039 if(!p_igetl(&guysbuf[i].e_tile,f))
50040 {
50041 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",14);
50042 }
50043
50044 if(!p_getc(&guysbuf[i].e_width,f))
50045 {
50046 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",15);
50047 }
50048
50049 if(!p_getc(&guysbuf[i].e_height,f))
50050 {
50051 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",16);
50052 }
50053
50054 if(!p_igetw(&guysbuf[i].hp,f))
50055 {
50056 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",17);
50057 }
50058
50059 if(!p_igetw(&guysbuf[i].family,f))
50060 {
50061 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",18);
50062 }
50063
50064 if(!p_igetw(&guysbuf[i].cset,f))
50065 {
50066 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",19);
50067 }
50068
50069 if(!p_igetw(&guysbuf[i].anim,f))
50070 {
50071 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",20);
50072 }
50073
50074 if(!p_igetw(&guysbuf[i].e_anim,f))
50075 {
50076 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",21);
50077 }
50078
50079 if(!p_igetw(&guysbuf[i].frate,f))
50080 {
50081 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",22);
50082 }
50083
50084 if(!p_igetw(&guysbuf[i].e_frate,f))
50085 {
50086 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",23);
50087 }
50088
50089 if(!p_igetw(&guysbuf[i].dp,f))
50090 {
50091 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",24);
50092 }
50093
50094 if(!p_igetw(&guysbuf[i].wdp,f))
50095 {
50096 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",25);
50097 }
50098
50099 if(!p_igetw(&guysbuf[i].weapon,f))
50100 {
50101 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",26);
50102 }
50103
50104 if(!p_igetw(&guysbuf[i].rate,f))
50105 {
50106 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",27);
50107 }
50108
50109 if(!p_igetw(&guysbuf[i].hrate,f))
50110 {
50111 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",28);
50112 }
50113
50114 if(!p_igetw(&guysbuf[i].step,f))
50115 {
50116 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",29);
50117 }
50118
50119 if(!p_igetw(&guysbuf[i].homing,f))
50120 {
50121 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",30);
50122 }
50123
50124 if(!p_igetw(&guysbuf[i].grumble,f))
50125 {
50126 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",31);
50127 }
50128
50129 if(!p_igetw(&guysbuf[i].item_set,f))
50130 {
50131 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",32);
50132 }
50133
50134 if(!p_igetl(&guysbuf[i].misc1,f))
50135 {
50136 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",33);
50137 }
50138
50139 if(!p_igetl(&guysbuf[i].misc2,f))
50140 {
50141 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",34);
50142 }
50143
50144 if(!p_igetl(&guysbuf[i].misc3,f))
50145 {
50146 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",35);
50147 }
50148
50149 if(!p_igetl(&guysbuf[i].misc4,f))
50150 {
50151 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",36);
50152 }
50153
50154 if(!p_igetl(&guysbuf[i].misc5,f))
50155 {
50156 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",37);
50157 }
50158
50159 if(!p_igetl(&guysbuf[i].misc6,f))
50160 {
50161 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",38);
50162 }
50163
50164 if(!p_igetl(&guysbuf[i].misc7,f))
50165 {
50166 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",39);
50167 }
50168
50169 if(!p_igetl(&guysbuf[i].misc8,f))
50170 {
50171 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",40);
50172 }
50173
50174 if(!p_igetl(&guysbuf[i].misc9,f))
50175 {
50176 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",41);
50177 }
50178
50179 if(!p_igetl(&guysbuf[i].misc10,f))
50180 {
50181 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",42);
50182 }
50183
50184 if(!p_igetw(&guysbuf[i].bgsfx,f))
50185 {
50186 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",43);
50187 }
50188
50189 if(!p_igetw(&guysbuf[i].bosspal,f))
50190 {
50191 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",44);
50192 }
50193
50194 if(!p_igetw(&guysbuf[i].extend,f))
50195 {
50196 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",45);
50197 }
50198
50199 for(int32_t j=0; j < edefLAST; j++)
50200 {
50201 if(!p_getc(&guysbuf[i].defense[j],f))
50202 {
50203 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",46);
50204 }
50205 }
50206
50207 if(!p_getc(&guysbuf[i].hitsfx,f))
50208 {
50209 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",47);
50210 }
50211
50212 if(!p_getc(&guysbuf[i].deadsfx,f))
50213 {
50214 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",48);
50215 }
50216
50217 if(!p_igetl(&guysbuf[i].misc11,f))
50218 {
50219 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",49);
50220 }
50221
50222 if(!p_igetl(&guysbuf[i].misc12,f))
50223 {
50224 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",50);
50225 }
50226
50227 //New 2.6 defences
50228 for(int32_t j=edefLAST; j < edefLAST255; j++)
50229 {
50230 if(!p_getc(&guysbuf[i].defense[j],f))
50231 {
50232 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",51);
50233 }
50234 }
50235
50236 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
50237 if(!p_igetl(&guysbuf[i].txsz,f))
50238 {
50239 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",52);
50240 }
50241 if(!p_igetl(&guysbuf[i].tysz,f))
50242 {
50243 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",53);
50244 }
50245 if(!p_igetl(&guysbuf[i].hxsz,f))
50246 {
50247 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",54);
50248 }
50249 if(!p_igetl(&guysbuf[i].hysz,f))
50250 {
50251 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",55);
50252 }
50253 if(!p_igetl(&guysbuf[i].hzsz,f))
50254 {
50255 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",56);
50256 }
50257 // These are not fixed types, but ints, so they are safe to use here.
50258 if(!p_igetl(&guysbuf[i].hxofs,f))
50259 {
50260 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",57);
50261 }
50262 if(!p_igetl(&guysbuf[i].hyofs,f))
50263 {
50264 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",58);
50265 }
50266 if(!p_igetl(&guysbuf[i].xofs,f))
50267 {
50268 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",59);
50269 }
50270 if(!p_igetl(&guysbuf[i].yofs,f))
50271 {
50272 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",60);
50273 }
50274 if(!p_igetl(&guysbuf[i].zofs,f))
50275 {
50276 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",61);
50277 }
50278 if(!p_igetl(&guysbuf[i].wpnsprite,f))
50279 {
50280 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",62);
50281 }
50282 if(!p_igetl(&guysbuf[i].SIZEflags,f))
50283 {
50284 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",63);
50285 }
50286 if(!p_igetl(&guysbuf[i].frozentile,f))
50287 {
50288 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",64);
50289 }
50290 if(!p_igetl(&guysbuf[i].frozencset,f))
50291 {
50292 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",65);
50293 }
50294 if(!p_igetl(&guysbuf[i].frozenclock,f))
50295 {
50296 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",66);
50297 }
50298
50299 for ( int32_t q = 0; q < 10; q++ )
50300 {
50301 if(!p_igetw(&guysbuf[i].frozenmisc[q],f))
50302 {
50303 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",67);
50304 }
50305 }
50306 if(!p_igetw(&guysbuf[i].firesfx,f))
50307 {
50308 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",68);
50309 }
50310 //misc 16->31
50311 if(!p_igetl(&guysbuf[i].misc16,f))
50312 {
50313 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",69);
50314 }
50315 if(!p_igetl(&guysbuf[i].misc17,f))
50316 {
50317 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",70);
50318 }
50319 if(!p_igetl(&guysbuf[i].misc18,f))
50320 {
50321 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",71);
50322 }
50323 if(!p_igetl(&guysbuf[i].misc19,f))
50324 {
50325 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",72);
50326 }
50327 if(!p_igetl(&guysbuf[i].misc20,f))
50328 {
50329 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",73);
50330 }
50331 if(!p_igetl(&guysbuf[i].misc21,f))
50332 {
50333 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",74);
50334 }
50335 if(!p_igetl(&guysbuf[i].misc22,f))
50336 {
50337 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",75);
50338 }
50339 if(!p_igetl(&guysbuf[i].misc23,f))
50340 {
50341 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",76);
50342 }
50343 if(!p_igetl(&guysbuf[i].misc24,f))
50344 {
50345 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",77);
50346 }
50347 if(!p_igetl(&guysbuf[i].misc25,f))
50348 {
50349 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",78);
50350 }
50351 if(!p_igetl(&guysbuf[i].misc26,f))
50352 {
50353 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",79);
50354 }
50355 if(!p_igetl(&guysbuf[i].misc27,f))
50356 {
50357 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",80);
50358 }
50359 if(!p_igetl(&guysbuf[i].misc28,f))
50360 {
50361 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",81);
50362 }
50363 if(!p_igetl(&guysbuf[i].misc29,f))
50364 {
50365 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",82);
50366 }
50367 if(!p_igetl(&guysbuf[i].misc30,f))
50368 {
50369 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",83);
50370 }
50371 if(!p_igetl(&guysbuf[i].misc31,f))
50372 {
50373 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",84);
50374 }
50375 if(!p_igetl(&guysbuf[i].misc32,f))
50376 {
50377 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",85);
50378 }
50379 for ( int32_t q = 0; q < 32; q++ )
50380 {
50381 if(!p_igetl(&guysbuf[i].movement[q],f))
50382 {
50383 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",86);
50384 }
50385 }
50386 for ( int32_t q = 0; q < 32; q++ )
50387 {
50388 if(!p_igetl(&guysbuf[i].new_weapon[q],f))
50389 {
50390 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",87);
50391 }
50392 }
50393 if(!p_igetw(&guysbuf[i].script,f))
50394 {
50395 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",88);
50396 }
50397 for ( int32_t q = 0; q < 8; q++ )
50398 {
50399 if(!p_igetl(&guysbuf[i].initD[q],f))
50400 {
50401 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",89);
50402 }
50403 }
50404 for ( int32_t q = 0; q < 2; q++ )
50405 {
50406 if(!p_igetl(&guysbuf[i].initA[q],f))
50407 {
50408 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",90);
50409 }
50410 }
50411 if(!p_igetl(&guysbuf[i].editorflags,f))
50412 {
50413 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",91);
50414 }
50415 //somehow forgot these in the older builds -Z
50416 if(!p_igetl(&guysbuf[i].misc13,f))
50417 {
50418 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",92);
50419 }
50420 if(!p_igetl(&guysbuf[i].misc14,f))
50421 {
50422 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",93);
50423 }
50424 if(!p_igetl(&guysbuf[i].misc15,f))
50425 {
50426 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",94);
50427 }
50428
50429 //Enemy Editor InitD[] labels
50430 for ( int32_t q = 0; q < 8; q++ )
50431 {
50432 for ( int32_t w = 0; w < 65; w++ )
50433 {
50434 if(!p_getc(&guysbuf[i].initD_label[q][w],f))
50435 {
50436 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",95);
50437 }
50438 }
50439 for ( int32_t w = 0; w < 65; w++ )
50440 {
50441 if(!p_getc(&guysbuf[i].weapon_initD_label[q][w],f))
50442 {
50443 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",96);
50444 }
50445 }
50446 }
50447 if(!p_igetw(&guysbuf[i].weaponscript,f))
50448 {
50449 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",97);
50450 }
50451 //eweapon initD
50452 for ( int32_t q = 0; q < 8; q++ )
50453 {
50454 if(!p_igetl(&guysbuf[i].weap_initiald[q],f))
50455 {
50456 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",98);
50457 }
50458 }
50459
50460 }
50461 }
50462
50463 void FFScript::write_enemies(PACKFILE *f, int32_t vers_id)
50464 {
50465 if ( !f ) return;
50466 for(int32_t i=0; i<MAXGUYS; i++)
50467 {
50468 if(!p_iputl(guysbuf[i].flags,f))
50469 {
50470 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",6);
50471 }
50472
50473 if(!p_iputl(guysbuf[i].flags2,f))
50474 {
50475 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",7);
50476 }
50477
50478 if(!p_iputl(guysbuf[i].tile,f))
50479 {
50480 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",8);
50481 }
50482
50483 if(!p_putc(guysbuf[i].width,f))
50484 {
50485 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",9);
50486 }
50487
50488 if(!p_putc(guysbuf[i].height,f))
50489 {
50490 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",10);
50491 }
50492
50493 if(!p_iputl(guysbuf[i].s_tile,f))
50494 {
50495 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",11);
50496 }
50497
50498 if(!p_putc(guysbuf[i].s_width,f))
50499 {
50500 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",12);
50501 }
50502
50503 if(!p_putc(guysbuf[i].s_height,f))
50504 {
50505 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",13);
50506 }
50507
50508 if(!p_iputl(guysbuf[i].e_tile,f))
50509 {
50510 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",14);
50511 }
50512
50513 if(!p_putc(guysbuf[i].e_width,f))
50514 {
50515 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",15);
50516 }
50517
50518 if(!p_putc(guysbuf[i].e_height,f))
50519 {
50520 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",16);
50521 }
50522
50523 if(!p_iputw(guysbuf[i].hp,f))
50524 {
50525 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",17);
50526 }
50527
50528 if(!p_iputw(guysbuf[i].family,f))
50529 {
50530 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",18);
50531 }
50532
50533 if(!p_iputw(guysbuf[i].cset,f))
50534 {
50535 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",19);
50536 }
50537
50538 if(!p_iputw(guysbuf[i].anim,f))
50539 {
50540 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",20);
50541 }
50542
50543 if(!p_iputw(guysbuf[i].e_anim,f))
50544 {
50545 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",21);
50546 }
50547
50548 if(!p_iputw(guysbuf[i].frate,f))
50549 {
50550 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",22);
50551 }
50552
50553 if(!p_iputw(guysbuf[i].e_frate,f))
50554 {
50555 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",23);
50556 }
50557
50558 if(!p_iputw(guysbuf[i].dp,f))
50559 {
50560 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",24);
50561 }
50562
50563 if(!p_iputw(guysbuf[i].wdp,f))
50564 {
50565 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",25);
50566 }
50567
50568 if(!p_iputw(guysbuf[i].weapon,f))
50569 {
50570 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",26);
50571 }
50572
50573 if(!p_iputw(guysbuf[i].rate,f))
50574 {
50575 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",27);
50576 }
50577
50578 if(!p_iputw(guysbuf[i].hrate,f))
50579 {
50580 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",28);
50581 }
50582
50583 if(!p_iputw(guysbuf[i].step,f))
50584 {
50585 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",29);
50586 }
50587
50588 if(!p_iputw(guysbuf[i].homing,f))
50589 {
50590 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",30);
50591 }
50592
50593 if(!p_iputw(guysbuf[i].grumble,f))
50594 {
50595 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",31);
50596 }
50597
50598 if(!p_iputw(guysbuf[i].item_set,f))
50599 {
50600 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",32);
50601 }
50602
50603 if(!p_iputl(guysbuf[i].misc1,f))
50604 {
50605 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",33);
50606 }
50607
50608 if(!p_iputl(guysbuf[i].misc2,f))
50609 {
50610 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",34);
50611 }
50612
50613 if(!p_iputl(guysbuf[i].misc3,f))
50614 {
50615 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",35);
50616 }
50617
50618 if(!p_iputl(guysbuf[i].misc4,f))
50619 {
50620 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",36);
50621 }
50622
50623 if(!p_iputl(guysbuf[i].misc5,f))
50624 {
50625 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",37);
50626 }
50627
50628 if(!p_iputl(guysbuf[i].misc6,f))
50629 {
50630 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",38);
50631 }
50632
50633 if(!p_iputl(guysbuf[i].misc7,f))
50634 {
50635 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",39);
50636 }
50637
50638 if(!p_iputl(guysbuf[i].misc8,f))
50639 {
50640 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",40);
50641 }
50642
50643 if(!p_iputl(guysbuf[i].misc9,f))
50644 {
50645 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",41);
50646 }
50647
50648 if(!p_iputl(guysbuf[i].misc10,f))
50649 {
50650 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",42);
50651 }
50652
50653 if(!p_iputw(guysbuf[i].bgsfx,f))
50654 {
50655 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",43);
50656 }
50657
50658 if(!p_iputw(guysbuf[i].bosspal,f))
50659 {
50660 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",44);
50661 }
50662
50663 if(!p_iputw(guysbuf[i].extend,f))
50664 {
50665 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",45);
50666 }
50667
50668 for(int32_t j=0; j < edefLAST; j++)
50669 {
50670 if(!p_putc(guysbuf[i].defense[j],f))
50671 {
50672 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",46);
50673 }
50674 }
50675
50676 if(!p_putc(guysbuf[i].hitsfx,f))
50677 {
50678 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",47);
50679 }
50680
50681 if(!p_putc(guysbuf[i].deadsfx,f))
50682 {
50683 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",48);
50684 }
50685
50686 if(!p_iputl(guysbuf[i].misc11,f))
50687 {
50688 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",49);
50689 }
50690
50691 if(!p_iputl(guysbuf[i].misc12,f))
50692 {
50693 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",50);
50694 }
50695
50696 //New 2.6 defences
50697 for(int32_t j=edefLAST; j < edefLAST255; j++)
50698 {
50699 if(!p_putc(guysbuf[i].defense[j],f))
50700 {
50701 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",51);
50702 }
50703 }
50704
50705 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
50706 if(!p_iputl(guysbuf[i].txsz,f))
50707 {
50708 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",52);
50709 }
50710 if(!p_iputl(guysbuf[i].tysz,f))
50711 {
50712 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",53);
50713 }
50714 if(!p_iputl(guysbuf[i].hxsz,f))
50715 {
50716 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",54);
50717 }
50718 if(!p_iputl(guysbuf[i].hysz,f))
50719 {
50720 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",55);
50721 }
50722 if(!p_iputl(guysbuf[i].hzsz,f))
50723 {
50724 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",56);
50725 }
50726 // These are not fixed types, but ints, so they are safe to use here.
50727 if(!p_iputl(guysbuf[i].hxofs,f))
50728 {
50729 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",57);
50730 }
50731 if(!p_iputl(guysbuf[i].hyofs,f))
50732 {
50733 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",58);
50734 }
50735 if(!p_iputl(guysbuf[i].xofs,f))
50736 {
50737 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",59);
50738 }
50739 if(!p_iputl(guysbuf[i].yofs,f))
50740 {
50741 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",60);
50742 }
50743 if(!p_iputl(guysbuf[i].zofs,f))
50744 {
50745 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",61);
50746 }
50747 if(!p_iputl(guysbuf[i].wpnsprite,f))
50748 {
50749 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",62);
50750 }
50751 if(!p_iputl(guysbuf[i].SIZEflags,f))
50752 {
50753 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",63);
50754 }
50755 if(!p_iputl(guysbuf[i].frozentile,f))
50756 {
50757 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",64);
50758 }
50759 if(!p_iputl(guysbuf[i].frozencset,f))
50760 {
50761 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",65);
50762 }
50763 if(!p_iputl(guysbuf[i].frozenclock,f))
50764 {
50765 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",66);
50766 }
50767
50768 for ( int32_t q = 0; q < 10; q++ )
50769 {
50770 if(!p_iputw(guysbuf[i].frozenmisc[q],f))
50771 {
50772 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",67);
50773 }
50774 }
50775 if(!p_iputw(guysbuf[i].firesfx,f))
50776 {
50777 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",68);
50778 }
50779 //misc 16->31
50780 if(!p_iputl(guysbuf[i].misc16,f))
50781 {
50782 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",69);
50783 }
50784 if(!p_iputl(guysbuf[i].misc17,f))
50785 {
50786 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",70);
50787 }
50788 if(!p_iputl(guysbuf[i].misc18,f))
50789 {
50790 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",71);
50791 }
50792 if(!p_iputl(guysbuf[i].misc19,f))
50793 {
50794 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",72);
50795 }
50796 if(!p_iputl(guysbuf[i].misc20,f))
50797 {
50798 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",73);
50799 }
50800 if(!p_iputl(guysbuf[i].misc21,f))
50801 {
50802 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",74);
50803 }
50804 if(!p_iputl(guysbuf[i].misc22,f))
50805 {
50806 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",75);
50807 }
50808 if(!p_iputl(guysbuf[i].misc23,f))
50809 {
50810 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",76);
50811 }
50812 if(!p_iputl(guysbuf[i].misc24,f))
50813 {
50814 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",77);
50815 }
50816 if(!p_iputl(guysbuf[i].misc25,f))
50817 {
50818 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",78);
50819 }
50820 if(!p_iputl(guysbuf[i].misc26,f))
50821 {
50822 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",79);
50823 }
50824 if(!p_iputl(guysbuf[i].misc27,f))
50825 {
50826 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",80);
50827 }
50828 if(!p_iputl(guysbuf[i].misc28,f))
50829 {
50830 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",81);
50831 }
50832 if(!p_iputl(guysbuf[i].misc29,f))
50833 {
50834 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",82);
50835 }
50836 if(!p_iputl(guysbuf[i].misc30,f))
50837 {
50838 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",83);
50839 }
50840 if(!p_iputl(guysbuf[i].misc31,f))
50841 {
50842 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",84);
50843 }
50844 if(!p_iputl(guysbuf[i].misc32,f))
50845 {
50846 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",85);
50847 }
50848 for ( int32_t q = 0; q < 32; q++ )
50849 {
50850 if(!p_iputl(guysbuf[i].movement[q],f))
50851 {
50852 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",86);
50853 }
50854 }
50855 for ( int32_t q = 0; q < 32; q++ )
50856 {
50857 if(!p_iputl(guysbuf[i].new_weapon[q],f))
50858 {
50859 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",87);
50860 }
50861 }
50862 if(!p_iputw(guysbuf[i].script,f))
50863 {
50864 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",88);
50865 }
50866 for ( int32_t q = 0; q < 8; q++ )
50867 {
50868 if(!p_iputl(guysbuf[i].initD[q],f))
50869 {
50870 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",89);
50871 }
50872 }
50873 for ( int32_t q = 0; q < 2; q++ )
50874 {
50875 if(!p_iputl(guysbuf[i].initA[q],f))
50876 {
50877 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",90);
50878 }
50879 }
50880 if(!p_iputl(guysbuf[i].editorflags,f))
50881 {
50882 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",91);
50883 }
50884 //somehow forgot these in the older builds -Z
50885 if(!p_iputl(guysbuf[i].misc13,f))
50886 {
50887 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",92);
50888 }
50889 if(!p_iputl(guysbuf[i].misc14,f))
50890 {
50891 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",93);
50892 }
50893 if(!p_iputl(guysbuf[i].misc15,f))
50894 {
50895 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",94);
50896 }
50897
50898 //Enemy Editor InitD[] labels
50899 for ( int32_t q = 0; q < 8; q++ )
50900 {
50901 for ( int32_t w = 0; w < 65; w++ )
50902 {
50903 if(!p_putc(guysbuf[i].initD_label[q][w],f))
50904 {
50905 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",95);
50906 }
50907 }
50908 for ( int32_t w = 0; w < 65; w++ )
50909 {
50910 if(!p_putc(guysbuf[i].weapon_initD_label[q][w],f))
50911 {
50912 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",96);
50913 }
50914 }
50915 }
50916 if(!p_iputw(guysbuf[i].weaponscript,f))
50917 {
50918 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",97);
50919 }
50920 //eweapon initD
50921 for ( int32_t q = 0; q < 8; q++ )
50922 {
50923 if(!p_iputl(guysbuf[i].weap_initiald[q],f))
50924 {
50925 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",98);
50926 }
50927 }
50928
50929 }
50930 }
50931
50932
50933 void FFScript::write_items(PACKFILE *f, int32_t vers_id)
50934 {
50935 for(int32_t i=0; i<MAXITEMS; i++)
50936 {
50937 if(!p_iputl(itemsbuf[i].tile,f))
50938 {
50939 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",6);
50940 }
50941
50942 if(!p_putc(itemsbuf[i].misc_flags,f))
50943 {
50944 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",7);
50945 }
50946
50947 if(!p_putc(itemsbuf[i].csets,f))
50948 {
50949 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",8);
50950 }
50951
50952 if(!p_putc(itemsbuf[i].frames,f))
50953 {
50954 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",9);
50955 }
50956
50957 if(!p_putc(itemsbuf[i].speed,f))
50958 {
50959 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",10);
50960 }
50961
50962 if(!p_putc(itemsbuf[i].delay,f))
50963 {
50964 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",11);
50965 }
50966
50967 if(!p_iputl(itemsbuf[i].ltm,f))
50968 {
50969 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",12);
50970 }
50971
50972 if(!p_iputl(itemsbuf[i].family,f))
50973 {
50974 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",13);
50975 }
50976
50977 if(!p_putc(itemsbuf[i].fam_type,f))
50978 {
50979 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",14);
50980 }
50981
50982 if(!p_iputl(itemsbuf[i].power,f))
50983 {
50984 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",14);
50985 }
50986
50987 if(!p_iputl(itemsbuf[i].flags,f))
50988 {
50989 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",15);
50990 }
50991
50992 if(!p_iputw(itemsbuf[i].script,f))
50993 {
50994 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",16);
50995 }
50996
50997 if(!p_putc(itemsbuf[i].count,f))
50998 {
50999 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",17);
51000 }
51001
51002 if(!p_iputw(itemsbuf[i].amount,f))
51003 {
51004 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",18);
51005 }
51006
51007 if(!p_iputw(itemsbuf[i].collect_script,f))
51008 {
51009 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",19);
51010 }
51011
51012 if(!p_iputw(itemsbuf[i].setmax,f))
51013 {
51014 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",21);
51015 }
51016
51017 if(!p_iputw(itemsbuf[i].max,f))
51018 {
51019 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",22);
51020 }
51021
51022 if(!p_putc(itemsbuf[i].playsound,f))
51023 {
51024 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",23);
51025 }
51026
51027 for(int32_t j=0; j<8; j++)
51028 {
51029 if(!p_iputl(itemsbuf[i].initiald[j],f))
51030 {
51031 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",24);
51032 }
51033 }
51034
51035 for(int32_t j=0; j<2; j++)
51036 {
51037 if(!p_putc(itemsbuf[i].initiala[j],f))
51038 {
51039 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",25);
51040 }
51041 }
51042
51043 if(!p_putc(itemsbuf[i].wpn,f))
51044 {
51045 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",26);
51046 }
51047
51048 if(!p_putc(itemsbuf[i].wpn2,f))
51049 {
51050 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",27);
51051 }
51052
51053 if(!p_putc(itemsbuf[i].wpn3,f))
51054 {
51055 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",28);
51056 }
51057
51058 if(!p_putc(itemsbuf[i].wpn4,f))
51059 {
51060 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",29);
51061 }
51062
51063 if(!p_putc(itemsbuf[i].wpn5,f))
51064 {
51065 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",30);
51066 }
51067
51068 if(!p_putc(itemsbuf[i].wpn6,f))
51069 {
51070 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",31);
51071 }
51072
51073 if(!p_putc(itemsbuf[i].wpn7,f))
51074 {
51075 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",32);
51076 }
51077
51078 if(!p_putc(itemsbuf[i].wpn8,f))
51079 {
51080 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",33);
51081 }
51082
51083 if(!p_putc(itemsbuf[i].wpn9,f))
51084 {
51085 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",34);
51086 }
51087
51088 if(!p_putc(itemsbuf[i].wpn10,f))
51089 {
51090 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",35);
51091 }
51092
51093 if(!p_putc(itemsbuf[i].pickup_hearts,f))
51094 {
51095 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",36);
51096 }
51097
51098 if(!p_iputl(itemsbuf[i].misc1,f))
51099 {
51100 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",37);
51101 }
51102
51103 if(!p_iputl(itemsbuf[i].misc2,f))
51104 {
51105 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",38);
51106 }
51107
51108 if(!p_putc(itemsbuf[i].cost_amount[0],f))
51109 {
51110 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",39);
51111 }
51112
51113 if(!p_iputl(itemsbuf[i].misc3,f))
51114 {
51115 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",40);
51116 }
51117
51118 if(!p_iputl(itemsbuf[i].misc4,f))
51119 {
51120 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",41);
51121 }
51122
51123 if(!p_iputl(itemsbuf[i].misc5,f))
51124 {
51125 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",42);
51126 }
51127
51128 if(!p_iputl(itemsbuf[i].misc6,f))
51129 {
51130 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",43);
51131 }
51132
51133 if(!p_iputl(itemsbuf[i].misc7,f))
51134 {
51135 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",44);
51136 }
51137
51138 if(!p_iputl(itemsbuf[i].misc8,f))
51139 {
51140 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",45);
51141 }
51142
51143 if(!p_iputl(itemsbuf[i].misc9,f))
51144 {
51145 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",46);
51146 }
51147
51148 if(!p_iputl(itemsbuf[i].misc10,f))
51149 {
51150 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",47);
51151 }
51152
51153 if(!p_putc(itemsbuf[i].usesound,f))
51154 {
51155 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",48);
51156 }
51157
51158 if(!p_putc(itemsbuf[i].usesound2,f))
51159 {
51160 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",48);
51161 }
51162
51163 //New itemdata vars -Z
51164 //! version 27
51165
51166 if(!p_putc(itemsbuf[i].useweapon,f))
51167 {
51168 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",49);
51169 }
51170 if(!p_putc(itemsbuf[i].usedefence,f))
51171 {
51172 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",50);
51173 }
51174 if(!p_iputl(itemsbuf[i].weaprange,f))
51175 {
51176 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",51);
51177 }
51178 if(!p_iputl(itemsbuf[i].weapduration,f))
51179 {
51180 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",52);
51181 }
51182 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ ) {
51183 if(!p_iputl(itemsbuf[i].weap_pattern[q],f))
51184 {
51185 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",53);
51186 }
51187 }
51188 //version 28
51189 if(!p_iputl(itemsbuf[i].duplicates,f))
51190 {
51191 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",54);
51192 }
51193 for ( int32_t q = 0; q < INITIAL_D; q++ )
51194 {
51195 if(!p_iputl(itemsbuf[i].weap_initiald[q],f))
51196 {
51197 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",55);
51198 }
51199 }
51200 for ( int32_t q = 0; q < INITIAL_A; q++ )
51201 {
51202 if(!p_putc(itemsbuf[i].weap_initiala[q],f))
51203 {
51204 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",56);
51205 }
51206 }
51207
51208 if(!p_putc(itemsbuf[i].drawlayer,f))
51209 {
51210 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",57);
51211 }
51212
51213
51214 if(!p_iputl(itemsbuf[i].hxofs,f))
51215 {
51216 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",58);
51217 }
51218 if(!p_iputl(itemsbuf[i].hyofs,f))
51219 {
51220 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",59);
51221 }
51222 if(!p_iputl(itemsbuf[i].hxsz,f))
51223 {
51224 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",60);
51225 }
51226 if(!p_iputl(itemsbuf[i].hysz,f))
51227 {
51228 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",61);
51229 }
51230 if(!p_iputl(itemsbuf[i].hzsz,f))
51231 {
51232 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",62);
51233 }
51234 if(!p_iputl(itemsbuf[i].xofs,f))
51235 {
51236 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",63);
51237 }
51238 if(!p_iputl(itemsbuf[i].yofs,f))
51239 {
51240 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",64);
51241 }
51242 if(!p_iputl(itemsbuf[i].weap_hxofs,f))
51243 {
51244 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",65);
51245 }
51246 if(!p_iputl(itemsbuf[i].weap_hyofs,f))
51247 {
51248 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",66);
51249 }
51250 if(!p_iputl(itemsbuf[i].weap_hxsz,f))
51251 {
51252 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",67);
51253 }
51254 if(!p_iputl(itemsbuf[i].weap_hysz,f))
51255 {
51256 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",68);
51257 }
51258 if(!p_iputl(itemsbuf[i].weap_hzsz,f))
51259 {
51260 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",69);
51261 }
51262 if(!p_iputl(itemsbuf[i].weap_xofs,f))
51263 {
51264 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",70);
51265 }
51266 if(!p_iputl(itemsbuf[i].weap_yofs,f))
51267 {
51268 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",71);
51269 }
51270 if(!p_iputw(itemsbuf[i].weaponscript,f))
51271 {
51272 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",72);
51273 }
51274 if(!p_iputl(itemsbuf[i].wpnsprite,f))
51275 {
51276 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",73);
51277 }
51278 if(!p_iputl(itemsbuf[i].magiccosttimer[0],f))
51279 {
51280 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",74);
51281 }
51282 if(!p_iputl(itemsbuf[i].overrideFLAGS,f))
51283 {
51284 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",75);
51285 }
51286 if(!p_iputl(itemsbuf[i].tilew,f))
51287 {
51288 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",76);
51289 }
51290 if(!p_iputl(itemsbuf[i].tileh,f))
51291 {
51292 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",77);
51293 }
51294 if(!p_iputl(itemsbuf[i].weapoverrideFLAGS,f))
51295 {
51296 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",78);
51297 }
51298 if(!p_iputl(itemsbuf[i].weap_tilew,f))
51299 {
51300 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",79);
51301 }
51302 if(!p_iputl(itemsbuf[i].weap_tileh,f))
51303 {
51304 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",80);
51305 }
51306 if(!p_iputl(itemsbuf[i].pickup,f))
51307 {
51308 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",81);
51309 }
51310 if(!p_iputw(itemsbuf[i].pstring,f))
51311 {
51312 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",82);
51313 }
51314 if(!p_iputw(itemsbuf[i].pickup_string_flags,f))
51315 {
51316 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",83);
51317 }
51318
51319 if(!p_putc(itemsbuf[i].cost_counter[0],f))
51320 {
51321 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",84);
51322 }
51323
51324 //InitD[] labels
51325 for ( int32_t q = 0; q < 8; q++ )
51326 {
51327 for ( int32_t w = 0; w < 65; w++ )
51328 {
51329 if(!p_putc(itemsbuf[i].initD_label[q][w],f))
51330 {
51331 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",85);
51332 }
51333 }
51334 for ( int32_t w = 0; w < 65; w++ )
51335 {
51336 if(!p_putc(itemsbuf[i].weapon_initD_label[q][w],f))
51337 {
51338 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",86);
51339 }
51340 }
51341 for ( int32_t w = 0; w < 65; w++ )
51342 {
51343 if(!p_putc(itemsbuf[i].sprite_initD_label[q][w],f))
51344 {
51345 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",87);
51346 }
51347 }
51348 if(!p_iputl(itemsbuf[i].sprite_initiald[q],f))
51349 {
51350 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",88);
51351 }
51352 }
51353 for ( int32_t q = 0; q < 2; q++ )
51354 {
51355 if(!p_putc(itemsbuf[i].sprite_initiala[q],f))
51356 {
51357 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",89);
51358 }
51359
51360 }
51361 if(!p_iputw(itemsbuf[i].sprite_script,f))
51362 {
51363 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",90);
51364 }
51365
51366
51367 }
51368 }
51369
51370 void FFScript::read_items(PACKFILE *f, int32_t vers_id)
51371 {
51372 for(int32_t i=0; i<MAXITEMS; i++)
51373 {
51374 if(!p_igetl(&itemsbuf[i].tile,f))
51375 {
51376 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",6);
51377 }
51378
51379 if(!p_getc(&itemsbuf[i].misc_flags,f))
51380 {
51381 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",7);
51382 }
51383
51384 if(!p_getc(&itemsbuf[i].csets,f))
51385 {
51386 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",8);
51387 }
51388
51389 if(!p_getc(&itemsbuf[i].frames,f))
51390 {
51391 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",9);
51392 }
51393
51394 if(!p_getc(&itemsbuf[i].speed,f))
51395 {
51396 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",10);
51397 }
51398
51399 if(!p_getc(&itemsbuf[i].delay,f))
51400 {
51401 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",11);
51402 }
51403
51404 if(!p_igetl(&itemsbuf[i].ltm,f))
51405 {
51406 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",12);
51407 }
51408
51409 if(!p_igetl(&itemsbuf[i].family,f))
51410 {
51411 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",13);
51412 }
51413
51414 if(!p_getc(&itemsbuf[i].fam_type,f))
51415 {
51416 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",14);
51417 }
51418
51419 if(!p_igetl(&itemsbuf[i].power,f))
51420 {
51421 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",14);
51422 }
51423
51424 if(!p_igetl(&itemsbuf[i].flags,f))
51425 {
51426 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",15);
51427 }
51428
51429 if(!p_igetw(&itemsbuf[i].script,f))
51430 {
51431 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",16);
51432 }
51433
51434 if(!p_getc(&itemsbuf[i].count,f))
51435 {
51436 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",17);
51437 }
51438
51439 if(!p_igetw(&itemsbuf[i].amount,f))
51440 {
51441 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",18);
51442 }
51443
51444 if(!p_igetw(&itemsbuf[i].collect_script,f))
51445 {
51446 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",19);
51447 }
51448
51449 if(!p_igetw(&itemsbuf[i].setmax,f))
51450 {
51451 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",21);
51452 }
51453
51454 if(!p_igetw(&itemsbuf[i].max,f))
51455 {
51456 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",22);
51457 }
51458
51459 if(!p_getc(&itemsbuf[i].playsound,f))
51460 {
51461 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",23);
51462 }
51463
51464 for(int32_t j=0; j<8; j++)
51465 {
51466 if(!p_igetl(&itemsbuf[i].initiald[j],f))
51467 {
51468 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",24);
51469 }
51470 }
51471
51472 for(int32_t j=0; j<2; j++)
51473 {
51474 if(!p_getc(&itemsbuf[i].initiala[j],f))
51475 {
51476 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",25);
51477 }
51478 }
51479
51480 if(!p_getc(&itemsbuf[i].wpn,f))
51481 {
51482 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",26);
51483 }
51484
51485 if(!p_getc(&itemsbuf[i].wpn2,f))
51486 {
51487 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",27);
51488 }
51489
51490 if(!p_getc(&itemsbuf[i].wpn3,f))
51491 {
51492 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",28);
51493 }
51494
51495 if(!p_getc(&itemsbuf[i].wpn4,f))
51496 {
51497 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",29);
51498 }
51499
51500 if(!p_getc(&itemsbuf[i].wpn5,f))
51501 {
51502 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",30);
51503 }
51504
51505 if(!p_getc(&itemsbuf[i].wpn6,f))
51506 {
51507 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",31);
51508 }
51509
51510 if(!p_getc(&itemsbuf[i].wpn7,f))
51511 {
51512 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",32);
51513 }
51514
51515 if(!p_getc(&itemsbuf[i].wpn8,f))
51516 {
51517 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",33);
51518 }
51519
51520 if(!p_getc(&itemsbuf[i].wpn9,f))
51521 {
51522 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",34);
51523 }
51524
51525 if(!p_getc(&itemsbuf[i].wpn10,f))
51526 {
51527 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",35);
51528 }
51529
51530 if(!p_getc(&itemsbuf[i].pickup_hearts,f))
51531 {
51532 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",36);
51533 }
51534
51535 if(!p_igetl(&itemsbuf[i].misc1,f))
51536 {
51537 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",37);
51538 }
51539
51540 if(!p_igetl(&itemsbuf[i].misc2,f))
51541 {
51542 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",38);
51543 }
51544
51545 if(!p_getc(&itemsbuf[i].cost_amount[0],f))
51546 {
51547 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",39);
51548 }
51549
51550 if(!p_igetl(&itemsbuf[i].misc3,f))
51551 {
51552 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",40);
51553 }
51554
51555 if(!p_igetl(&itemsbuf[i].misc4,f))
51556 {
51557 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",41);
51558 }
51559
51560 if(!p_igetl(&itemsbuf[i].misc5,f))
51561 {
51562 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",42);
51563 }
51564
51565 if(!p_igetl(&itemsbuf[i].misc6,f))
51566 {
51567 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",43);
51568 }
51569
51570 if(!p_igetl(&itemsbuf[i].misc7,f))
51571 {
51572 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",44);
51573 }
51574
51575 if(!p_igetl(&itemsbuf[i].misc8,f))
51576 {
51577 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",45);
51578 }
51579
51580 if(!p_igetl(&itemsbuf[i].misc9,f))
51581 {
51582 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",46);
51583 }
51584
51585 if(!p_igetl(&itemsbuf[i].misc10,f))
51586 {
51587 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",47);
51588 }
51589
51590 if(!p_getc(&itemsbuf[i].usesound,f))
51591 {
51592 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",48);
51593 }
51594
51595 if(!p_getc(&itemsbuf[i].usesound2,f))
51596 {
51597 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",48);
51598 }
51599
51600 //New itemdata vars -Z
51601 //! version 27
51602
51603 if(!p_getc(&itemsbuf[i].useweapon,f))
51604 {
51605 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",49);
51606 }
51607 if(!p_getc(&itemsbuf[i].usedefence,f))
51608 {
51609 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",50);
51610 }
51611 if(!p_igetl(&itemsbuf[i].weaprange,f))
51612 {
51613 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",51);
51614 }
51615 if(!p_igetl(&itemsbuf[i].weapduration,f))
51616 {
51617 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",52);
51618 }
51619 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ ) {
51620 if(!p_igetl(&itemsbuf[i].weap_pattern[q],f))
51621 {
51622 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",53);
51623 }
51624 }
51625 //version 28
51626 if(!p_igetl(&itemsbuf[i].duplicates,f))
51627 {
51628 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",54);
51629 }
51630 for ( int32_t q = 0; q < INITIAL_D; q++ )
51631 {
51632 if(!p_igetl(&itemsbuf[i].weap_initiald[q],f))
51633 {
51634 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",55);
51635 }
51636 }
51637 for ( int32_t q = 0; q < INITIAL_A; q++ )
51638 {
51639 if(!p_getc(&itemsbuf[i].weap_initiala[q],f))
51640 {
51641 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",56);
51642 }
51643 }
51644
51645 if(!p_getc(&itemsbuf[i].drawlayer,f))
51646 {
51647 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",57);
51648 }
51649
51650
51651 if(!p_igetl(&itemsbuf[i].hxofs,f))
51652 {
51653 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",58);
51654 }
51655 if(!p_igetl(&itemsbuf[i].hyofs,f))
51656 {
51657 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",59);
51658 }
51659 if(!p_igetl(&itemsbuf[i].hxsz,f))
51660 {
51661 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",60);
51662 }
51663 if(!p_igetl(&itemsbuf[i].hysz,f))
51664 {
51665 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",61);
51666 }
51667 if(!p_igetl(&itemsbuf[i].hzsz,f))
51668 {
51669 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",62);
51670 }
51671 if(!p_igetl(&itemsbuf[i].xofs,f))
51672 {
51673 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",63);
51674 }
51675 if(!p_igetl(&itemsbuf[i].yofs,f))
51676 {
51677 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",64);
51678 }
51679 if(!p_igetl(&itemsbuf[i].weap_hxofs,f))
51680 {
51681 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",65);
51682 }
51683 if(!p_igetl(&itemsbuf[i].weap_hyofs,f))
51684 {
51685 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",66);
51686 }
51687 if(!p_igetl(&itemsbuf[i].weap_hxsz,f))
51688 {
51689 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",67);
51690 }
51691 if(!p_igetl(&itemsbuf[i].weap_hysz,f))
51692 {
51693 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",68);
51694 }
51695 if(!p_igetl(&itemsbuf[i].weap_hzsz,f))
51696 {
51697 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",69);
51698 }
51699 if(!p_igetl(&itemsbuf[i].weap_xofs,f))
51700 {
51701 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",70);
51702 }
51703 if(!p_igetl(&itemsbuf[i].weap_yofs,f))
51704 {
51705 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",71);
51706 }
51707 if(!p_igetw(&itemsbuf[i].weaponscript,f))
51708 {
51709 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",72);
51710 }
51711 if(!p_igetl(&itemsbuf[i].wpnsprite,f))
51712 {
51713 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",73);
51714 }
51715 if(!p_igetl(&itemsbuf[i].magiccosttimer[0],f))
51716 {
51717 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",74);
51718 }
51719 if(!p_igetl(&itemsbuf[i].overrideFLAGS,f))
51720 {
51721 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",75);
51722 }
51723 if(!p_igetl(&itemsbuf[i].tilew,f))
51724 {
51725 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",76);
51726 }
51727 if(!p_igetl(&itemsbuf[i].tileh,f))
51728 {
51729 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",77);
51730 }
51731 if(!p_igetl(&itemsbuf[i].weapoverrideFLAGS,f))
51732 {
51733 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",78);
51734 }
51735 if(!p_igetl(&itemsbuf[i].weap_tilew,f))
51736 {
51737 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",79);
51738 }
51739 if(!p_igetl(&itemsbuf[i].weap_tileh,f))
51740 {
51741 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",80);
51742 }
51743 if(!p_igetl(&itemsbuf[i].pickup,f))
51744 {
51745 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",81);
51746 }
51747 if(!p_igetw(&itemsbuf[i].pstring,f))
51748 {
51749 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",82);
51750 }
51751 if(!p_igetw(&itemsbuf[i].pickup_string_flags,f))
51752 {
51753 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",83);
51754 }
51755
51756 if(!p_getc(&itemsbuf[i].cost_counter[0],f))
51757 {
51758 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",84);
51759 }
51760
51761 //InitD[] labels
51762 for ( int32_t q = 0; q < 8; q++ )
51763 {
51764 for ( int32_t w = 0; w < 65; w++ )
51765 {
51766 if(!p_getc(&itemsbuf[i].initD_label[q][w],f))
51767 {
51768 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",85);
51769 }
51770 }
51771 for ( int32_t w = 0; w < 65; w++ )
51772 {
51773 if(!p_getc(&itemsbuf[i].weapon_initD_label[q][w],f))
51774 {
51775 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",86);
51776 }
51777 }
51778 for ( int32_t w = 0; w < 65; w++ )
51779 {
51780 if(!p_getc(&itemsbuf[i].sprite_initD_label[q][w],f))
51781 {
51782 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",87);
51783 }
51784 }
51785 if(!p_igetl(&itemsbuf[i].sprite_initiald[q],f))
51786 {
51787 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",88);
51788 }
51789 }
51790 for ( int32_t q = 0; q < 2; q++ )
51791 {
51792 if(!p_getc(&itemsbuf[i].sprite_initiala[q],f))
51793 {
51794 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",89);
51795 }
51796
51797 }
51798 if(!p_igetw(&itemsbuf[i].sprite_script,f))
51799 {
51800 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",90);
51801 }
51802
51803
51804 }
51805 }
51806
51807 void FFScript::write_mapscreens(PACKFILE *f,int32_t vers_id)
51808 {
51809 for(int32_t i=0; i<map_count && i<MAXMAPS; i++)
51810 {
51811 for(int32_t j=0; j<MAPSCRS; j++)
51812 {
51813 mapscr *m = &TheMaps[i*MAPSCRS+j];
51814
51815 if(!p_putc(m->valid,f))
51816 {
51817 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51818 }
51819
51820 if(!p_putc(m->guy,f))
51821 {
51822 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51823 }
51824
51825 {
51826 if(!p_iputw(m->str,f))
51827 {
51828 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51829 }
51830 }
51831
51832 if(!p_putc(m->room,f))
51833 {
51834 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51835 }
51836
51837 if(!p_putc(m->item,f))
51838 {
51839 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51840 }
51841
51842 if(!p_putc(m->hasitem, f))
51843 {
51844 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51845 }
51846
51847 for(int32_t k=0; k<4; k++)
51848 {
51849 if(!p_putc(m->tilewarptype[k],f))
51850 {
51851 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51852 }
51853 }
51854
51855 if(!p_iputw(m->door_combo_set,f))
51856 {
51857 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51858 }
51859
51860 for(int32_t k=0; k<4; k++)
51861 {
51862 if(!p_putc(m->warpreturnx[k],f))
51863 {
51864 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51865 }
51866 }
51867
51868 for(int32_t k=0; k<4; k++)
51869 {
51870 if(!p_putc(m->warpreturny[k],f))
51871 {
51872 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51873 }
51874 }
51875
51876 if(!p_iputw(m->warpreturnc,f))
51877 {
51878 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51879 }
51880
51881 if(!p_putc(m->stairx,f))
51882 {
51883 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51884 }
51885
51886 if(!p_putc(m->stairy,f))
51887 {
51888 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51889 }
51890
51891 if(!p_putc(m->itemx,f))
51892 {
51893 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51894 }
51895
51896 if(!p_putc(m->itemy,f))
51897 {
51898 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51899 }
51900
51901 if(!p_iputw(m->color,f))
51902 {
51903 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51904 }
51905
51906 if(!p_putc(m->enemyflags,f))
51907 {
51908 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51909 }
51910
51911 for(int32_t k=0; k<4; k++)
51912 {
51913 if(!p_putc(m->door[k],f))
51914 {
51915 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51916 }
51917 }
51918
51919 for(int32_t k=0; k<4; k++)
51920 {
51921 if(!p_iputw(m->tilewarpdmap[k],f))
51922 {
51923 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51924 }
51925 }
51926
51927 for(int32_t k=0; k<4; k++)
51928 {
51929 if(!p_putc(m->tilewarpscr[k],f))
51930 {
51931 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51932 }
51933 }
51934
51935 if(!p_putc(m->tilewarpoverlayflags,f))
51936 {
51937 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51938 }
51939
51940 if(!p_putc(m->exitdir,f))
51941 {
51942 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51943 }
51944
51945 for(int32_t k=0; k<10; k++)
51946 {
51947 {
51948 if(!p_iputw(m->enemy[k],f))
51949 {
51950 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51951 }
51952 }
51953 }
51954
51955 if(!p_putc(m->pattern,f))
51956 {
51957 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51958 }
51959
51960 for(int32_t k=0; k<4; k++)
51961 {
51962 if(!p_putc(m->sidewarptype[k],f))
51963 {
51964 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51965 }
51966 }
51967
51968 if(!p_putc(m->sidewarpoverlayflags,f))
51969 {
51970 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51971 }
51972
51973 if(!p_putc(m->warparrivalx,f))
51974 {
51975 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51976 }
51977
51978 if(!p_putc(m->warparrivaly,f))
51979 {
51980 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51981 }
51982
51983 for(int32_t k=0; k<4; k++)
51984 {
51985 if(!p_putc(m->path[k],f))
51986 {
51987 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51988 }
51989 }
51990
51991 for(int32_t k=0; k<4; k++)
51992 {
51993 if(!p_putc(m->sidewarpscr[k],f))
51994 {
51995 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
51996 }
51997 }
51998
51999 for(int32_t k=0; k<4; k++)
52000 {
52001 if(!p_iputw(m->sidewarpdmap[k],f))
52002 {
52003 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52004 }
52005 }
52006
52007 if(!p_putc(m->sidewarpindex,f))
52008 {
52009 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52010 }
52011
52012 if(!p_iputw(m->undercombo,f))
52013 {
52014 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52015 }
52016
52017 if(!p_putc(m->undercset,f))
52018 {
52019 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52020 }
52021
52022 if(!p_iputw(m->catchall,f))
52023 {
52024 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52025 }
52026
52027 if(!p_putc(m->flags,f))
52028 {
52029 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52030 }
52031
52032 if(!p_putc(m->flags2,f))
52033 {
52034 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52035 }
52036
52037 if(!p_putc(m->flags3,f))
52038 {
52039 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52040 }
52041
52042 if(!p_putc(m->flags4,f))
52043 {
52044 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52045 }
52046
52047 if(!p_putc(m->flags5,f))
52048 {
52049 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52050 }
52051
52052 if(!p_iputw(m->noreset,f))
52053 {
52054 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52055 }
52056
52057 if(!p_iputw(m->nocarry,f))
52058 {
52059 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52060 }
52061
52062 if(!p_putc(m->flags6,f))
52063 {
52064 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52065 }
52066
52067 if(!p_putc(m->flags7,f))
52068 {
52069 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52070 }
52071
52072 if(!p_putc(m->flags8,f))
52073 {
52074 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52075 }
52076
52077 if(!p_putc(m->flags9,f))
52078 {
52079 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52080 }
52081
52082 if(!p_putc(m->flags10,f))
52083 {
52084 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52085 }
52086
52087 if(!p_putc(m->csensitive,f))
52088 {
52089 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52090 }
52091
52092 if(!p_putc(m->oceansfx,f))
52093 {
52094 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52095 }
52096
52097 if(!p_putc(m->bosssfx,f))
52098 {
52099 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52100 }
52101
52102 if(!p_putc(m->secretsfx,f))
52103 {
52104 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52105 }
52106
52107 if(!p_putc(m->holdupsfx,f))
52108 {
52109 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52110 }
52111
52112 for(int32_t k=0; k<6; k++)
52113 {
52114 if(!p_putc(m->layermap[k],f))
52115 {
52116 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52117 }
52118 }
52119
52120 for(int32_t k=0; k<6; k++)
52121 {
52122 if(!p_putc(m->layerscreen[k],f))
52123 {
52124 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52125 }
52126 }
52127
52128 for(int32_t k=0; k<6; k++)
52129 {
52130 if(!p_putc(m->layeropacity[k],f))
52131 {
52132 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52133 }
52134 }
52135
52136 if(!p_iputw(m->timedwarptics,f))
52137 {
52138 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52139 }
52140
52141 if(!p_putc(m->nextmap,f))
52142 {
52143 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52144 }
52145
52146 if(!p_putc(m->nextscr,f))
52147 {
52148 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52149 }
52150
52151 for(int32_t k=0; k<128; k++)
52152 {
52153 if(!p_iputw(m->secretcombo[k],f))
52154 {
52155 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52156 }
52157 }
52158
52159 for(int32_t k=0; k<128; k++)
52160 {
52161 if(!p_putc(m->secretcset[k],f))
52162 {
52163 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52164 }
52165 }
52166
52167 for(int32_t k=0; k<128; k++)
52168 {
52169 if(!p_putc(m->secretflag[k],f))
52170 {
52171 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52172 }
52173 }
52174
52175 for(int32_t k=0; k<176; k++)
52176 {
52177 try
52178 {
52179 if(!p_iputw(m->data[k],f))
52180 {
52181 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52182 }
52183 }
52184 catch(std::out_of_range& )
52185 {
52186 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52187 }
52188 }
52189
52190 for(int32_t k=0; k<176; k++)
52191 {
52192 try
52193 {
52194 if(!p_putc(m->sflag[k], f))
52195 {
52196 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52197 }
52198 }
52199 catch(std::out_of_range& )
52200 {
52201 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52202 }
52203 }
52204
52205 for(int32_t k=0; k<176; k++)
52206 {
52207 try
52208 {
52209 if(!p_putc(m->cset[k],f))
52210 {
52211 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52212 }
52213 }
52214 catch(std::out_of_range& )
52215 {
52216 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52217 }
52218 }
52219
52220 if(!p_iputw(m->screen_midi,f))
52221 {
52222 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52223 }
52224
52225 if(!p_putc(m->lens_layer,f))
52226 {
52227 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52228 }
52229
52230 for(int32_t k=0; k<32; k++)
52231 {
52232
52233 if(!p_iputw(m->ffcs[k].getData(),f))
52234 {
52235 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52236 }
52237
52238 if(!p_putc(m->ffcs[k].cset,f))
52239 {
52240 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52241 }
52242
52243 if(!p_iputw(m->ffcs[k].delay,f))
52244 {
52245 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52246 }
52247
52248 if(!p_iputzf(m->ffcs[k].x,f))
52249 {
52250 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52251 }
52252
52253 if(!p_iputzf(m->ffcs[k].y,f))
52254 {
52255 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52256 }
52257
52258 if(!p_iputzf(m->ffcs[k].vx,f))
52259 {
52260 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52261 }
52262
52263 if(!p_iputzf(m->ffcs[k].vy,f))
52264 {
52265 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52266 }
52267
52268 if(!p_iputzf(m->ffcs[k].ax,f))
52269 {
52270 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52271 }
52272
52273 if(!p_iputzf(m->ffcs[k].ay,f))
52274 {
52275 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52276 }
52277
52278 if(!p_putc(m->ffcs[k].link,f))
52279 {
52280 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52281 }
52282
52283 if(!p_iputl(m->ffcs[k].hit_width,f))
52284 {
52285 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52286 }
52287
52288 if(!p_iputl(m->ffcs[k].hit_height,f))
52289 {
52290 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52291 }
52292
52293 if(!p_putc(m->ffcs[k].txsz,f))
52294 {
52295 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52296 }
52297
52298 if(!p_putc(m->ffcs[k].tysz,f))
52299 {
52300 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52301 }
52302
52303 if(!p_iputl(m->ffcs[k].flags,f))
52304 {
52305 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52306 }
52307
52308 if(!p_iputw(m->ffcs[k].script,f))
52309 {
52310 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52311 }
52312
52313 if(!p_iputl(m->ffcs[k].initd[0],f))
52314 {
52315 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52316 }
52317
52318 if(!p_iputl(m->ffcs[k].initd[1],f))
52319 {
52320 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52321 }
52322
52323 if(!p_iputl(m->ffcs[k].initd[2],f))
52324 {
52325 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52326 }
52327
52328 if(!p_iputl(m->ffcs[k].initd[3],f))
52329 {
52330 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52331 }
52332
52333 if(!p_iputl(m->ffcs[k].initd[4],f))
52334 {
52335 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52336 }
52337
52338 if(!p_iputl(m->ffcs[k].initd[5],f))
52339 {
52340 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52341 }
52342
52343 if(!p_iputl(m->ffcs[k].initd[6],f))
52344 {
52345 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52346 }
52347
52348 if(!p_iputl(m->ffcs[k].initd[7],f))
52349 {
52350 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52351 }
52352
52353 }
52354
52355 for ( int32_t q = 0; q < 10; q++ )
52356 {
52357 if(!p_iputl(m->npcstrings[q],f))
52358 {
52359 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52360 }
52361 }
52362 for ( int32_t q = 0; q < 10; q++ )
52363 {
52364 if(!p_iputw(m->new_items[q],f))
52365 {
52366 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52367 }
52368 }
52369 for ( int32_t q = 0; q < 10; q++ )
52370 {
52371 if(!p_iputw(m->new_item_x[q],f))
52372 {
52373 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52374 }
52375 }
52376 for ( int32_t q = 0; q < 10; q++ )
52377 {
52378 if(!p_iputw(m->new_item_y[q],f))
52379 {
52380 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52381 }
52382 }
52383 if(!p_iputw(m->script,f))
52384 {
52385 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52386 }
52387 for ( int32_t q = 0; q < 8; q++ )
52388 {
52389 if(!p_iputl(m->screeninitd[q],f))
52390 {
52391 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52392 }
52393
52394 }
52395 if(!p_putc(m->preloadscript,f))
52396 {
52397 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52398 }
52399
52400 if(!p_putc(m->hidelayers,f))
52401 {
52402 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52403 }
52404 if(!p_putc(m->hidescriptlayers,f))
52405 {
52406 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
52407 }
52408
52409
52410 } //end mapscr for loop
52411 }
52412 }
52413 void FFScript::read_mapscreens(PACKFILE *f,int32_t vers_id)
52414 {
52415 for(int32_t i=0; i<map_count && i<MAXMAPS; i++)
52416 {
52417 for(int32_t j=0; j<MAPSCRS; j++)
52418 {
52419 mapscr *m = &TheMaps[i*MAPSCRS+j];
52420
52421 if(!p_getc(&(m->valid),f))
52422 {
52423 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52424 }
52425
52426 if(!p_getc(&(m->guy),f))
52427 {
52428 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52429 }
52430
52431 {
52432 if(!p_igetw(&(m->str),f))
52433 {
52434 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52435 }
52436 }
52437
52438 if(!p_getc(&(m->room),f))
52439 {
52440 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52441 }
52442
52443 if(!p_getc(&(m->item),f))
52444 {
52445 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52446 }
52447
52448 if(!p_getc(&(m->hasitem), f))
52449 {
52450 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52451 }
52452
52453 for(int32_t k=0; k<4; k++)
52454 {
52455 if(!p_getc(&(m->tilewarptype[k]),f))
52456 {
52457 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52458 }
52459 }
52460
52461 if(!p_igetw(&(m->door_combo_set),f))
52462 {
52463 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52464 }
52465
52466 for(int32_t k=0; k<4; k++)
52467 {
52468 if(!p_getc(&(m->warpreturnx[k]),f))
52469 {
52470 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52471 }
52472 }
52473
52474 for(int32_t k=0; k<4; k++)
52475 {
52476 if(!p_getc(&(m->warpreturny[k]),f))
52477 {
52478 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52479 }
52480 }
52481
52482 if(!p_igetw(&(m->warpreturnc),f))
52483 {
52484 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52485 }
52486
52487 if(!p_getc(&(m->stairx),f))
52488 {
52489 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52490 }
52491
52492 if(!p_getc(&(m->stairy),f))
52493 {
52494 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52495 }
52496
52497 if(!p_getc(&(m->itemx),f))
52498 {
52499 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52500 }
52501
52502 if(!p_getc(&(m->itemy),f))
52503 {
52504 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52505 }
52506
52507 if(!p_igetw(&(m->color),f))
52508 {
52509 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52510 }
52511
52512 if(!p_getc(&(m->enemyflags),f))
52513 {
52514 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52515 }
52516
52517 for(int32_t k=0; k<4; k++)
52518 {
52519 if(!p_getc(&(m->door[k]),f))
52520 {
52521 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52522 }
52523 }
52524
52525 for(int32_t k=0; k<4; k++)
52526 {
52527 if(!p_igetw(&(m->tilewarpdmap[k]),f))
52528 {
52529 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52530 }
52531 }
52532
52533 for(int32_t k=0; k<4; k++)
52534 {
52535 if(!p_getc(&(m->tilewarpscr[k]),f))
52536 {
52537 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52538 }
52539 }
52540
52541 if(!p_getc(&(m->tilewarpoverlayflags),f))
52542 {
52543 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52544 }
52545
52546 if(!p_getc(&(m->exitdir),f))
52547 {
52548 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52549 }
52550
52551 for(int32_t k=0; k<10; k++)
52552 {
52553 {
52554 if(!p_igetw(&(m->enemy[k]),f))
52555 {
52556 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52557 }
52558 }
52559 }
52560
52561 if(!p_getc(&(m->pattern),f))
52562 {
52563 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52564 }
52565
52566 for(int32_t k=0; k<4; k++)
52567 {
52568 if(!p_getc(&(m->sidewarptype[k]),f))
52569 {
52570 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52571 }
52572 }
52573
52574 if(!p_getc(&(m->sidewarpoverlayflags),f))
52575 {
52576 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52577 }
52578
52579 if(!p_getc(&(m->warparrivalx),f))
52580 {
52581 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52582 }
52583
52584 if(!p_getc(&(m->warparrivaly),f))
52585 {
52586 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52587 }
52588
52589 for(int32_t k=0; k<4; k++)
52590 {
52591 if(!p_getc(&(m->path[k]),f))
52592 {
52593 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52594 }
52595 }
52596
52597 for(int32_t k=0; k<4; k++)
52598 {
52599 if(!p_getc(&(m->sidewarpscr[k]),f))
52600 {
52601 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52602 }
52603 }
52604
52605 for(int32_t k=0; k<4; k++)
52606 {
52607 if(!p_igetw(&(m->sidewarpdmap[k]),f))
52608 {
52609 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52610 }
52611 }
52612
52613 if(!p_getc(&(m->sidewarpindex),f))
52614 {
52615 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52616 }
52617
52618 if(!p_igetw(&(m->undercombo),f))
52619 {
52620 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52621 }
52622
52623 if(!p_getc(&(m->undercset),f))
52624 {
52625 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52626 }
52627
52628 if(!p_igetw(&(m->catchall),f))
52629 {
52630 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52631 }
52632
52633 if(!p_getc(&(m->flags),f))
52634 {
52635 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52636 }
52637
52638 if(!p_getc(&(m->flags2),f))
52639 {
52640 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52641 }
52642
52643 if(!p_getc(&(m->flags3),f))
52644 {
52645 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52646 }
52647
52648 if(!p_getc(&(m->flags4),f))
52649 {
52650 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52651 }
52652
52653 if(!p_getc(&(m->flags5),f))
52654 {
52655 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52656 }
52657
52658 if(!p_igetw(&(m->noreset),f))
52659 {
52660 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52661 }
52662
52663 if(!p_igetw(&(m->nocarry),f))
52664 {
52665 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52666 }
52667
52668 if(!p_getc(&(m->flags6),f))
52669 {
52670 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52671 }
52672
52673 if(!p_getc(&(m->flags7),f))
52674 {
52675 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52676 }
52677
52678 if(!p_getc(&(m->flags8),f))
52679 {
52680 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52681 }
52682
52683 if(!p_getc(&(m->flags9),f))
52684 {
52685 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52686 }
52687
52688 if(!p_getc(&(m->flags10),f))
52689 {
52690 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52691 }
52692
52693 if(!p_getc(&(m->csensitive),f))
52694 {
52695 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52696 }
52697
52698 if(!p_getc(&(m->oceansfx),f))
52699 {
52700 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52701 }
52702
52703 if(!p_getc(&(m->bosssfx),f))
52704 {
52705 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52706 }
52707
52708 if(!p_getc(&(m->secretsfx),f))
52709 {
52710 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52711 }
52712
52713 if(!p_getc(&(m->holdupsfx),f))
52714 {
52715 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52716 }
52717
52718 for(int32_t k=0; k<6; k++)
52719 {
52720 if(!p_getc(&(m->layermap[k]),f))
52721 {
52722 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52723 }
52724 }
52725
52726 for(int32_t k=0; k<6; k++)
52727 {
52728 if(!p_getc(&(m->layerscreen[k]),f))
52729 {
52730 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52731 }
52732 }
52733
52734 for(int32_t k=0; k<6; k++)
52735 {
52736 if(!p_getc(&(m->layeropacity[k]),f))
52737 {
52738 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52739 }
52740 }
52741
52742 if(!p_igetw(&(m->timedwarptics),f))
52743 {
52744 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52745 }
52746
52747 if(!p_getc(&(m->nextmap),f))
52748 {
52749 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52750 }
52751
52752 if(!p_getc(&(m->nextscr),f))
52753 {
52754 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52755 }
52756
52757 for(int32_t k=0; k<128; k++)
52758 {
52759 if(!p_igetw(&(m->secretcombo[k]),f))
52760 {
52761 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52762 }
52763 }
52764
52765 for(int32_t k=0; k<128; k++)
52766 {
52767 if(!p_getc(&(m->secretcset[k]),f))
52768 {
52769 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52770 }
52771 }
52772
52773 for(int32_t k=0; k<128; k++)
52774 {
52775 if(!p_getc(&(m->secretflag[k]),f))
52776 {
52777 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52778 }
52779 }
52780
52781 for(int32_t k=0; k<176; k++)
52782 {
52783 try
52784 {
52785 if(!p_igetw(&(m->data[k]),f))
52786 {
52787 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52788 }
52789 }
52790 catch(std::out_of_range& )
52791 {
52792 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52793 }
52794 }
52795
52796 for(int32_t k=0; k<176; k++)
52797 {
52798 try
52799 {
52800 if(!p_getc(&(m->sflag[k]),f))
52801 {
52802 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52803 }
52804 }
52805 catch(std::out_of_range& )
52806 {
52807 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52808 }
52809 }
52810
52811 for(int32_t k=0; k<176; k++)
52812 {
52813 try
52814 {
52815 if(!p_getc(&(m->cset[k]),f))
52816 {
52817 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52818 }
52819 }
52820 catch(std::out_of_range& )
52821 {
52822 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52823 }
52824 }
52825
52826 if(!p_igetw(&(m->screen_midi),f))
52827 {
52828 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52829 }
52830
52831 if(!p_getc(&(m->lens_layer),f))
52832 {
52833 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52834 }
52835 word tempw;
52836 for(int32_t k=0; k<32; k++)
52837 {
52838
52839 if(!p_igetw(&tempw,f))
52840 {
52841 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52842 }
52843 m->ffcs[k].setData(tempw);
52844
52845 if(!p_getc(&(m->ffcs[k].cset),f))
52846 {
52847 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52848 }
52849
52850 if(!p_igetw(&(m->ffcs[k].delay),f))
52851 {
52852 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52853 }
52854
52855 if(!p_igetzf(&(m->ffcs[k].x),f))
52856 {
52857 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52858 }
52859
52860 if(!p_igetzf(&(m->ffcs[k].y),f))
52861 {
52862 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52863 }
52864
52865 if(!p_igetzf(&(m->ffcs[k].vx),f))
52866 {
52867 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52868 }
52869
52870 if(!p_igetzf(&(m->ffcs[k].vy),f))
52871 {
52872 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52873 }
52874
52875 if(!p_igetzf(&(m->ffcs[k].ax),f))
52876 {
52877 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52878 }
52879
52880 if(!p_igetzf(&(m->ffcs[k].ay),f))
52881 {
52882 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52883 }
52884
52885 if(!p_getc(&(m->ffcs[k].link),f))
52886 {
52887 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52888 }
52889
52890 if(!p_igetl(&(m->ffcs[k].hit_width),f))
52891 {
52892 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52893 }
52894
52895 if(!p_igetl(&(m->ffcs[k].hit_height),f))
52896 {
52897 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52898 }
52899
52900 if(!p_getc(&(m->ffcs[k].txsz),f))
52901 {
52902 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52903 }
52904
52905 if(!p_getc(&(m->ffcs[k].tysz),f))
52906 {
52907 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52908 }
52909
52910 if(!p_igetl(&(m->ffcs[k].flags),f))
52911 {
52912 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52913 }
52914
52915 if(!p_igetw(&(m->ffcs[k].script),f))
52916 {
52917 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52918 }
52919
52920 if(!p_igetl(&(m->ffcs[k].initd[0]),f))
52921 {
52922 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52923 }
52924
52925 if(!p_igetl(&(m->ffcs[k].initd[1]),f))
52926 {
52927 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52928 }
52929
52930 if(!p_igetl(&(m->ffcs[k].initd[2]),f))
52931 {
52932 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52933 }
52934
52935 if(!p_igetl(&(m->ffcs[k].initd[3]),f))
52936 {
52937 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52938 }
52939
52940 if(!p_igetl(&(m->ffcs[k].initd[4]),f))
52941 {
52942 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52943 }
52944
52945 if(!p_igetl(&(m->ffcs[k].initd[5]),f))
52946 {
52947 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52948 }
52949
52950 if(!p_igetl(&(m->ffcs[k].initd[6]),f))
52951 {
52952 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52953 }
52954
52955 if(!p_igetl(&(m->ffcs[k].initd[7]),f))
52956 {
52957 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52958 }
52959
52960 }
52961
52962 for ( int32_t q = 0; q < 10; q++ )
52963 {
52964 if(!p_igetl(&(m->npcstrings[q]),f))
52965 {
52966 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52967 }
52968 }
52969 for ( int32_t q = 0; q < 10; q++ )
52970 {
52971 if(!p_igetw(&(m->new_items[q]),f))
52972 {
52973 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52974 }
52975 }
52976 for ( int32_t q = 0; q < 10; q++ )
52977 {
52978 if(!p_igetw(&(m->new_item_x[q]),f))
52979 {
52980 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52981 }
52982 }
52983 for ( int32_t q = 0; q < 10; q++ )
52984 {
52985 if(!p_igetw(&(m->new_item_y[q]),f))
52986 {
52987 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52988 }
52989 }
52990 if(!p_igetw(&(m->script),f))
52991 {
52992 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52993 }
52994 for ( int32_t q = 0; q < 8; q++ )
52995 {
52996 if(!p_igetl(&(m->screeninitd[q]),f))
52997 {
52998 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
52999 }
53000
53001 }
53002 if(!p_getc(&(m->preloadscript),f))
53003 {
53004 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53005 }
53006
53007 if ( vers_id >= 2 )
53008 {
53009 if(!p_getc(&(m->hidelayers),f))
53010 {
53011 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53012 }
53013 if(!p_getc(&(m->hidescriptlayers),f))
53014 {
53015 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
53016 }
53017
53018 }
53019
53020
53021 }//end mapscr all for loop
53022
53023 }
53024 }
53025 /*
53026 void FFScript::write_maps(PACKFILE *f, int32_t vers_id)
53027 {
53028 for(int32_t i=0; i<map_count && i<MAXMAPS; i++)
53029 {
53030 for(int32_t j=0; j<MAPSCRS; j++)
53031 {
53032 if ( !(FFCore.write_mapscreen(f,i,j,vers_id)) )
53033 {
53034 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODE: %d",i*j);
53035 }
53036 }
53037 }
53038 }
53039
53040 void FFScript::read_maps(PACKFILE *f, int32_t vers_id)
53041 {
53042 for(int32_t i=0; i<map_count && i<MAXMAPS; i++)
53043 {
53044 for(int32_t j=0; j<MAPSCRS; j++)
53045 {
53046 if ( !(FFCore.read_mapscreen(f,i,j,vers_id)) )
53047 {
53048 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE: %d",i*j);
53049 }
53050 }
53051 }
53052 }
53053 */
53054
53055
53056 int32_t FFScript::getHeroOTile(int32_t index1, int32_t index2)
53057 {
53058 {
53059 herospritetype lst = (herospritetype)index1;
53060 int32_t dir = index2;
53061 int32_t the_ret = 0;
53062 switch(lst)
53063 {
53064 case LSprwalkspr: the_ret = walkspr[dir][0]; break;
53065 case LSprstabspr: the_ret = stabspr[dir][0]; break;
53066 case LSprslashspr: the_ret = slashspr[dir][0]; break;
53067 case LSprrevslashspr: the_ret = revslashspr[dir][0]; break;
53068 case LSprfloatspr: the_ret = floatspr[dir][0]; break;
53069 case LSprswimspr: the_ret = swimspr[dir][0]; break;
53070 case LSprdivespr: the_ret = divespr[dir][0]; break;
53071 case LSprdrownspr: the_ret = drowningspr[dir][0]; break;
53072 case LSprsidedrownspr: the_ret = sidedrowningspr[dir][0]; break;
53073 case LSprlavadrownspr: the_ret = drowning_lavaspr[dir][0]; break;
53074 case LSprsideswimspr: the_ret = sideswimspr[dir][0]; break;
53075 case LSprsideswimslashspr: the_ret = sideswimslashspr[dir][0]; break;
53076 case LSprsideswimstabspr: the_ret = sideswimstabspr[dir][0]; break;
53077 case LSprsideswimpoundspr: the_ret = sideswimpoundspr[dir][0]; break;
53078 case LSprsideswimchargespr: the_ret = sideswimchargespr[dir][0]; break;
53079 case LSprpoundspr: the_ret = poundspr[dir][0]; break;
53080 case LSprjumpspr: the_ret = jumpspr[dir][0]; break;
53081 case LSprchargespr: the_ret = chargespr[dir][0]; break;
53082 case LSprcastingspr: the_ret = castingspr[0]; break;
53083 case LSprsideswimcastingspr: the_ret = sideswimcastingspr[0]; break;
53084 case LSprholdspr1: the_ret = holdspr[0][0][0]; break;
53085 case LSprholdspr2: the_ret = holdspr[0][1][0]; break;
53086 case LSprholdsprw1: the_ret = holdspr[1][0][0]; break;
53087 case LSprholdsprw2: the_ret = holdspr[1][1][0]; break;
53088 case LSprholdsprSw1: the_ret = sideswimholdspr[0][0]; break;
53089 case LSprholdsprSw2: the_ret = sideswimholdspr[1][0]; break;
53090 default: the_ret = 0;
53091 }
53092
53093 return the_ret*10000;
53094 }
53095 }
53096
53097 defWpnSprite FFScript::getDefWeaponSprite(int32_t wpnid)
53098 {
53099 switch(wpnid)
53100 {
53101 case wNone: return ws_0;
53102 case wSword: return ws_0;
53103 case wBeam: return wsBeam;
53104 case wBrang : return wsBrang;
53105 case wBomb: return wsBomb;
53106 case wSBomb: return wsSBomb;
53107 case wLitBomb: return wsBombblast;
53108 case wLitSBomb: return wsBombblast;
53109 case wArrow: return wsArrow;
53110 case wFire: return wsFire;
53111 case wWhistle: return wsUnused45;
53112 case wBait: return wsBait;
53113 case wWand: return wsWandHandle;
53114 case wMagic: return wsMagic;
53115 case wCatching: return wsUnused45;
53116 case wWind: return wsWind;
53117 case wRefMagic: return wsRefMagic;
53118 case wRefFireball: return wsRefFireball;
53119 case wRefRock: return wsRock;
53120 case wHammer: return wsHammer;
53121 case wHookshot: return wsHookshotHead;
53122 case wHSHandle: return wsHookshotHandle;
53123 case wHSChain: return wsHookshotChainH;
53124 case wSSparkle: return wsSilverSparkle;
53125 case wFSparkle: return wsGoldSparkle;
53126 case wSmack: return wsHammerSmack;
53127 case wPhantom: return wsUnused45;
53128 case wCByrna: return wsByrnaCane;
53129 case wRefBeam: return wsRefBeam;
53130 case wStomp: return wsUnused45;
53131 case lwMax: return wsUnused45;
53132 case wScript1:
53133 case wScript2:
53134 case wScript3:
53135 case wScript4:
53136 case wScript5:
53137 case wScript6:
53138 case wScript7:
53139 case wScript8:
53140 case wScript9:
53141 case wScript10: return ws_0;
53142 case wIce: return wsIce; //new
53143 case wFlame: return wsEFire2; //new
53144 //not implemented; t/b/a
53145 case wSound:
53146 case wThrown:
53147 case wPot:
53148 case wLit:
53149 case wBombos:
53150 case wEther:
53151 case wQuake:
53152 case wSword180:
53153 case wSwordLA: return wsUnused45;
53154
53155 case ewFireball: return wsFireball2;
53156 case ewArrow: return wsEArrow;
53157 case ewBrang: return wsBrang;
53158 case ewSword: return wsEBeam;
53159 case ewRock: return wsRock;
53160 case ewMagic: return wsEMagic;
53161 case ewBomb: return wsEBomb;
53162 case ewSBomb: return wsESbomb;
53163 case ewLitBomb: return wsEBombblast;
53164 case ewLitSBomb: return wsESbombblast;
53165 case ewFireTrail: return wsEFiretrail;
53166 case ewFlame: return wsEFire;
53167 case ewWind: return wsEWind;
53168 case ewFlame2: return wsEFire2;
53169 case ewFlame2Trail: return wsEFiretrail2;
53170 case ewIce: return wsIce;
53171 case ewFireball2: return wsFireball2;
53172 default: return wsUnused45;
53173 }
53174 };
53175
53176
53177 12 int32_t FFScript::getEnemyByScriptUID(int32_t sUID)
53178 {
53179
53180
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 for(word i = 0; i < guys.Count(); i++)
53181 {
53182 27 enemy *w = (enemy*)guys.spr(i);
53183
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 15 times.
27 if ( w ->script_UID == sUID ) return i;
53184 15 }
53185 return -1;
53186 12 }
53187
53188 598 int32_t FFScript::getLWeaponByScriptUID(int32_t sUID)
53189 {
53190
53191
1/2
✓ Branch 0 taken 2168 times.
✗ Branch 1 not taken.
2168 for(word i = 0; i < Lwpns.Count(); i++)
53192 {
53193 2168 weapon *w = (weapon*)Lwpns.spr(i);
53194
2/2
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 1570 times.
2168 if ( w ->script_UID == sUID ) return i;
53195 1570 }
53196 return -1;
53197 598 }
53198
53199 int32_t FFScript::getEWeaponByScriptUID(int32_t sUID)
53200 {
53201
53202 for(word i = 0; i < Ewpns.Count(); i++)
53203 {
53204 weapon *w = (weapon*)Ewpns.spr(i);
53205 if ( w ->script_UID == sUID ) return i;
53206 }
53207 return -1;
53208 }
53209
53210
53211 598 void FFScript::do_loadlweapon_by_script_uid(const bool v)
53212 {
53213 598 int32_t sUID = SH::get_arg(sarg1, v); //literal, not div by 10000
53214
53215 598 int32_t indx = FFCore.getLWeaponByScriptUID(sUID);
53216
1/2
✓ Branch 0 taken 598 times.
✗ Branch 1 not taken.
598 if ( indx > -1 )
53217 598 ri->lwpn = Lwpns.spr(indx)->getUID();
53218 else
53219 {
53220 ri->lwpn = 0;
53221 if(get_qr(qr_LOG_INVALID_UID_LOAD))
53222 Z_scripterrlog("There is no valid LWeapon associated with UID (%) at this time.\nThe UID is stale, or invalid.\n", sUID);
53223 }
53224 598 }
53225
53226 void FFScript::do_loadeweapon_by_script_uid(const bool v)
53227 {
53228
53229 int32_t sUID = SH::get_arg(sarg1, v); //literal, not div by 10000
53230
53231 int32_t indx = FFCore.getEWeaponByScriptUID(sUID);
53232 if ( indx > -1 )
53233 ri->ewpn = Ewpns.spr(indx)->getUID();
53234 else
53235 {
53236 ri->ewpn = 0;
53237 if(get_qr(qr_LOG_INVALID_UID_LOAD))
53238 Z_scripterrlog("There is no valid EWeapon associated with UID (%) at this time.\nThe UID is stale, or invalid.\n", sUID);
53239 }
53240 }
53241
53242
53243 12 void FFScript::do_loadnpc_by_script_uid(const bool v)
53244 {
53245
53246 12 int32_t sUID = SH::get_arg(sarg1, v); //literal, not div by 10000
53247
53248 12 int32_t indx = FFCore.getEnemyByScriptUID(sUID);
53249
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if ( indx > -1 )
53250 12 ri->guyref = guys.spr(indx)->getUID();
53251 else
53252 {
53253 ri->guyref = 0;
53254 if(get_qr(qr_LOG_INVALID_UID_LOAD))
53255 Z_scripterrlog("There is no valid NPC associated with UID (%) at this time.\nThe UID is stale, or invalid.\n", sUID);
53256 }
53257 12 }
53258
53259 //Combo Scripts
53260
53261 58864 void FFScript::clear_combo_scripts()
53262 {
53263 58864 memset(combo_id_cache, -1, sizeof(combo_id_cache));
53264 58864 clear_script_engine_data_of_type(ScriptType::Combo);
53265 58864 }
53266
53267 3018 void FFScript::clear_combo_script(int32_t lyr, int32_t pos)
53268 {
53269
1/2
✓ Branch 0 taken 3018 times.
✗ Branch 1 not taken.
3018 if(lyr < 0) return;
53270
53271
53272 3018 int32_t index = get_combopos_ref(pos, lyr);
53273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3018 times.
3018 if (index >= 176*7) return;
53274
53275 3018 combo_id_cache[index] = -1;
53276 3018 combopos_modified = index;
53277 3018 clear_script_engine_data(ScriptType::Combo, index);
53278 3018 }
53279
53280 int32_t FFScript::getComboDataLayer(int32_t c, ScriptType scripttype)
53281 {
53282 if ( scripttype != ScriptType::Combo )
53283 {
53284 Z_scripterrlog("combodata->Layer() only runs from combo scripts, not from script type &s\n", ScriptTypeToString(scripttype));
53285 return -1;
53286 }
53287 else
53288 {
53289 int32_t l = 0;
53290 for (int32_t q = 176; q < 1232; q+= 176 )
53291 {
53292 if ( c < q )
53293 {
53294 return l;
53295 }
53296 ++l;
53297 }
53298 return -1;
53299 }
53300 }
53301
53302 int32_t FFScript::getCombodataPos(int32_t c, ScriptType scripttype)
53303 {
53304 if ( scripttype != ScriptType::Combo )
53305 {
53306 Z_scripterrlog("combodata->Pos() only runs from combo scripts, not from script type &s\n", ScriptTypeToString(scripttype));
53307 return -1;
53308 }
53309 else return ((c%176));
53310 }
53311
53312 int32_t FFScript::getCombodataX(int32_t c, ScriptType scripttype)
53313 {
53314 if ( scripttype != ScriptType::Combo )
53315 {
53316 Z_scripterrlog("combodata->X() only runs from combo scripts, not from script type &s\n", ScriptTypeToString(scripttype));
53317 return -1;
53318 }
53319 else
53320 {
53321 int32_t pos = getCombodataPos(c, scripttype);
53322 return COMBOX(pos);
53323 }
53324 }
53325
53326 int32_t FFScript::getCombodataY(int32_t c, ScriptType scripttype)
53327 {
53328 if ( scripttype != ScriptType::Combo )
53329 {
53330 Z_scripterrlog("combodata->Y() only runs from combo scripts, not from script type &s\n", ScriptTypeToString(scripttype));
53331 return -1;
53332 }
53333 else
53334 {
53335 int32_t pos = getCombodataPos(c, scripttype);
53336 return COMBOY(pos);
53337 }
53338 }
53339
53340 void FFScript::ClearComboScripts()
53341 {
53342 for ( int32_t c = 0; c < 176; c++ )
53343 {
53344 reset_script_engine_data(ScriptType::Combo, c);
53345 }
53346 }
53347
53348 631671 int32_t FFScript::combo_script_engine(const bool preload, const bool waitdraw)
53349 {
53350 ///non-scripted effects
53351
2/2
✓ Branch 0 taken 4421697 times.
✓ Branch 1 taken 631671 times.
5053368 for ( int32_t q = 0; q < 7; ++q )
53352 {
53353
2/2
✓ Branch 0 taken 562947 times.
✓ Branch 1 taken 3858750 times.
4421697 if (!get_qr(qr_COMBOSCRIPTS_LAYER_0+q))
53354 3858750 continue;
53355
2/2
✓ Branch 0 taken 99078672 times.
✓ Branch 1 taken 562947 times.
99641619 for ( int32_t c = 0; c < 176; ++c )
53356 {
53357 // int32_t ls = (q ? tmpscr->layerscreen[q-1] : 0);
53358 // int32_t lm = (q ? tmpscr->layermap[q-1] : 0);
53359 // if(q && !lm) continue; //No layer for this screen
53360 99078672 int32_t idval = get_combopos_ref(c, q);
53361 99078672 mapscr* m = FFCore.tempScreens[q]; //get templayer mapscr for any layer (including 0)
53362 99078672 word cid = m->data[c];
53363
1/2
✓ Branch 0 taken 99078672 times.
✗ Branch 1 not taken.
99078672 if(combo_id_cache[idval] < 0)
53364 combo_id_cache[idval] = cid;
53365
2/2
✓ Branch 0 taken 98917601 times.
✓ Branch 1 taken 161071 times.
99078672 else if(combo_id_cache[idval] != cid)
53366 {
53367 161071 combopos_modified = idval;
53368 161071 combo_id_cache[idval] = cid;
53369 161071 clear_script_engine_data(ScriptType::Combo, idval);
53370 161071 }
53371
53372
2/2
✓ Branch 0 taken 98954904 times.
✓ Branch 1 taken 123768 times.
99078672 if ( combobuf[cid].script )
53373 {
53374 123768 auto& data = get_script_engine_data(ScriptType::Combo, idval);
53375
2/2
✓ Branch 0 taken 47615 times.
✓ Branch 1 taken 76153 times.
123768 if (data.doscript)
53376 {
53377
3/4
✓ Branch 0 taken 38064 times.
✓ Branch 1 taken 38089 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38064 times.
76153 if (waitdraw && !data.waitdraw) continue;
53378
53379 38089 ZScriptVersion::RunScript(ScriptType::Combo, combobuf[cid].script, idval);
53380
1/2
✓ Branch 0 taken 38089 times.
✗ Branch 1 not taken.
38089 if (waitdraw) data.waitdraw = false;
53381 38089 }
53382 85704 }
53383 99040608 }
53384 562947 }
53385 631671 return 1;
53386 }
53387
53388 //Config for file->
53389
53390 /* ______ ___ ___
53391 * /\ _ \ /\_ \ /\_ \
53392 * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
53393 * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
53394 * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
53395 * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
53396 * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
53397 * /\____/
53398 * \_/__/
53399 *
53400 * Ported from Allegro 4.4.3.1 Configuration routines.
53401 *
53402 * By Shawn Hargreaves; C++ Port by ZoriaRPG
53403 *
53404 * Hook functions added by Martijn Versteegh.
53405 *
53406 * Annie Testes lifted several hardcoded length limitations.
53407 *
53408 * See readme.txt for copyright information.
53409 */
53410
53411
53412 #include "allegro.h"
53413 #include "allegro/internal/aintern.h"
53414
53415
53416
53417
53418
53419 /* zscript_flush_config:
53420 * Writes out a config structure to disk if the contents
53421 * have changed.
53422 */
53423 void zscript_flush_config(ZSCRIPT_CONFIG *cfg)
53424 {
53425 ZSCRIPT_CONFIG_ENTRY *pos;
53426 PACKFILE *f;
53427 char cr[16];
53428
53429 usetc(cr+usetc(cr, '\n'), 0);
53430
53431 if (cfg && cfg->filename && cfg->dirty)
53432 {
53433 /* write changed data to disk */
53434 f = pack_fopen(cfg->filename, F_WRITE);
53435
53436 if (f)
53437 {
53438 pos = cfg->head;
53439
53440 while (pos)
53441 {
53442 if (pos->name)
53443 {
53444 pack_fputs(pos->name, f);
53445
53446 if (ugetc(pos->name) != '[')
53447 {
53448 pack_putc(' ', f);
53449 pack_putc('=', f);
53450 pack_putc(' ', f);
53451 }
53452 }
53453
53454 if (pos->data)
53455 pack_fputs(pos->data, f);
53456
53457 pack_fputs(cr, f);
53458
53459 pos = pos->next;
53460 }
53461
53462 pack_fclose(f);
53463 cfg->dirty = FALSE;
53464 }
53465 }
53466 }
53467
53468
53469
53470 /* zscript_flush_config_file:
53471 * Writes out the config file to disk if the contents
53472 * have changed.
53473 */
53474 void zscript_flush_config_file(void)
53475 {
53476 zscript_flush_config(config[0]);
53477 }
53478
53479
53480
53481 /* zscript_destroy_config:
53482 * Destroys a config structure, writing it out to disk if the contents
53483 * have changed.
53484 */
53485 void zscript_destroy_config(ZSCRIPT_CONFIG *cfg)
53486 {
53487 ZSCRIPT_CONFIG_ENTRY *pos, *prev;
53488
53489 if (cfg)
53490 {
53491 zscript_flush_config(cfg);
53492
53493 if (cfg->filename)
53494 _AL_FREE(cfg->filename);
53495
53496 /* destroy the variable list */
53497 pos = cfg->head;
53498
53499 while (pos)
53500 {
53501 prev = pos;
53502 pos = pos->next;
53503
53504 if (prev->name)
53505 _AL_FREE(prev->name);
53506
53507 if (prev->data)
53508 _AL_FREE(prev->data);
53509
53510 _AL_FREE(prev);
53511 }
53512
53513 _AL_FREE(cfg);
53514 }
53515 }
53516
53517
53518
53519 /* zscript_config_cleanup:
53520 * Called at shutdown time to free memory being used by the config routines,
53521 * and write any changed data out to disk.
53522 */
53523 void zscript_config_cleanup(void)
53524 {
53525 ZSCRIPT_CONFIG_HOOK *hook, *nexthook;
53526 int32_t i;
53527
53528 for (i=0; i<MAX_CONFIGS; i++)
53529 {
53530 if (config[i])
53531 {
53532 zscript_destroy_config(config[i]);
53533 config[i] = NULL;
53534 }
53535 }
53536
53537 if (config_override)
53538 {
53539 zscript_destroy_config(config_override);
53540 config_override = NULL;
53541 }
53542
53543 if (config_language)
53544 {
53545 zscript_destroy_config(config_language);
53546 config_language = NULL;
53547 }
53548
53549 if (system_config)
53550 {
53551 zscript_destroy_config(system_config);
53552 system_config = NULL;
53553 }
53554
53555 if (config_hook)
53556 {
53557 hook = config_hook;
53558
53559 while (hook)
53560 {
53561 if (hook->section)
53562 _AL_FREE(hook->section);
53563
53564 nexthook = hook->next;
53565 _AL_FREE(hook);
53566 hook = nexthook;
53567 }
53568
53569 config_hook = NULL;
53570 }
53571
53572 _AL_FREE(config_argv);
53573 config_argv = NULL;
53574
53575 _AL_FREE(argv_buf);
53576 argv_buf = NULL;
53577
53578 argv_buf_size = 0;
53579
53580 _remove_exit_func(zscript_config_cleanup);
53581 config_installed = FALSE;
53582 }
53583
53584
53585
53586 /* zscript_init_config:
53587 * Sets up the configuration routines ready for use, also loading the
53588 * default config file if the loaddata flag is set and no other config
53589 * file is in memory.
53590 */
53591 void zscript_init_config(int32_t loaddata)
53592 {
53593 char filename[1024], tmp[128], *cfg_name;
53594
53595 if (!config_installed)
53596 {
53597 _add_exit_func(zscript_config_cleanup, "zscript_config_cleanup");
53598 config_installed = TRUE;
53599 }
53600
53601 if ((loaddata) && (!config[0]))
53602 {
53603 cfg_name = uconvert_ascii("allegro.cfg", tmp);
53604
53605 if (find_allegro_resource(filename, cfg_name, NULL, NULL, NULL, NULL, NULL, sizeof(filename)) != 0)
53606 {
53607 get_executable_name(filename, sizeof(filename));
53608 usetc(get_filename(filename), 0);
53609 ustrzcat(filename, sizeof(filename), cfg_name);
53610 }
53611
53612 zscript_set_config_file(filename);
53613 }
53614
53615 if (!system_config)
53616 {
53617 system_config = (struct ZSCRIPT_CONFIG*)malloc(sizeof(ZSCRIPT_CONFIG));
53618 if (system_config)
53619 {
53620 system_config->head = NULL;
53621 system_config->filename = NULL;
53622 system_config->dirty = FALSE;
53623 }
53624 }
53625 }
53626
53627
53628
53629 /* zscript_get_config_line:
53630 * Helper for splitting files up into individual lines. Returns the length
53631 * in bytes of the sequence of characters delimited by the first EOL marker
53632 * in the array DATA of length LENGTH, and allocates NAME and VAL to record
53633 * the name and the value of the config entry respectively; otherwise set
53634 * NAME to NULL and returns a copy of the line through VAL if the line was
53635 * blank or a comment. Returns -1 and set allegro_errno on failure.
53636 */
53637 int32_t zscript_get_config_line(const char *data, int32_t length, char **name, char **val)
53638 {
53639 char *buf;
53640 int32_t buf_size=256;
53641 int32_t inpos, outpos, i, j;
53642 int32_t c, c2, w0;
53643
53644 inpos = 0;
53645 outpos = 0;
53646 w0 = ucwidth(0);
53647
53648 buf = (char*)_AL_MALLOC_ATOMIC(buf_size);
53649 if (!buf)
53650 {
53651 *allegro_errno = ENOMEM;
53652 return -1;
53653 }
53654
53655 /* search for an EOL marker */
53656 while (inpos<length)
53657 {
53658 c = ugetc(data+inpos);
53659 if ((c == '\r') || (c == '\n'))
53660 {
53661 inpos += uwidth(data+inpos);
53662 if (inpos < length)
53663 {
53664 c2 = ugetc(data+inpos);
53665 if (((c == '\r') && (c2 == '\n')) || ((c == '\n') && (c2 == '\r')))
53666 inpos += uwidth(data+inpos);
53667 }
53668 break;
53669 }
53670
53671 /* increase the buffer size if needed */
53672 if (outpos>=(int32_t)buf_size-w0)
53673 {
53674 buf_size *= 2;
53675 buf = (char*)_al_sane_realloc(buf, buf_size);
53676 if (!buf)
53677 {
53678 *allegro_errno = ENOMEM;
53679 return -1;
53680 }
53681 }
53682
53683 outpos += usetc(buf+outpos, c);
53684 inpos += uwidth(data+inpos);
53685 }
53686
53687 usetc(buf+outpos, 0);
53688
53689 /* skip leading spaces */
53690 i = 0;
53691 c = ugetc(buf);
53692
53693 while ((c) && (uisspace(c)))
53694 {
53695 i += uwidth(buf+i);
53696 c = ugetc(buf+i);
53697 }
53698
53699 /* read name string */
53700 j = 0;
53701
53702 /* compute name length */
53703 while ((c) && (!uisspace(c)) && (c != '=') && (c != '#'))
53704 {
53705 j += ucwidth(c);
53706 i += uwidth(buf+i);
53707 c = ugetc(buf+i);
53708 }
53709
53710 if (j)
53711 {
53712 /* got a variable */
53713 *name = (char*)_AL_MALLOC_ATOMIC(j+w0);
53714 if (!(*name))
53715 {
53716 *allegro_errno = ENOMEM;
53717 _AL_FREE(buf);
53718 return -1;
53719 }
53720
53721 ustrzcpy(*name, j+w0, buf+i-j);
53722
53723 while ((c) && ((uisspace(c)) || (c == '=')))
53724 {
53725 i += uwidth(buf+i);
53726 c = ugetc(buf+i);
53727 }
53728
53729 *val = _al_ustrdup(buf+i);
53730 if (!(*val))
53731 {
53732 _AL_FREE(name);
53733 _AL_FREE(buf);
53734 return -1;
53735 }
53736
53737 /* strip trailing spaces */
53738 i = ustrlen(*val) - 1;
53739 while ((i >= 0) && (uisspace(ugetat(*val, i))))
53740 usetat(*val, i--, 0);
53741 }
53742 else
53743 {
53744 /* blank line or comment */
53745 *name = NULL;
53746 *val = _al_ustrdup(buf);
53747 if (!(*val))
53748 {
53749 _AL_FREE(buf);
53750 return -1;
53751 }
53752 }
53753
53754 _AL_FREE(buf);
53755
53756 return inpos;
53757 }
53758
53759
53760
53761 /* zscript_set_config:
53762 * Does the work of setting up a config structure.
53763 */
53764 void zscript_set_config(ZSCRIPT_CONFIG **config, const char *data, int32_t length, const char *filename)
53765 {
53766 ZSCRIPT_CONFIG_ENTRY **prev, *p;
53767 char *name, *val;
53768 int32_t ret, pos;
53769
53770 zscript_init_config(FALSE);
53771
53772 if (*config)
53773 {
53774 zscript_destroy_config(*config);
53775 *config = NULL;
53776 }
53777
53778 *config = (struct ZSCRIPT_CONFIG*)_AL_MALLOC(sizeof(ZSCRIPT_CONFIG));
53779 if (!(*config))
53780 {
53781 *allegro_errno = ENOMEM;
53782 return;
53783 }
53784
53785 (*config)->head = NULL;
53786 (*config)->dirty = FALSE;
53787
53788 if (filename)
53789 {
53790 (*config)->filename = _al_ustrdup(filename);
53791 if (!(*config)->filename)
53792 {
53793 _AL_FREE(*config);
53794 *config = NULL;
53795 return;
53796 }
53797 }
53798 else
53799 (*config)->filename = NULL;
53800
53801 prev = &(*config)->head;
53802 pos = 0;
53803
53804 while (pos < length)
53805 {
53806 ret = zscript_get_config_line(data+pos, length-pos, &name, &val);
53807 if (ret<0)
53808 {
53809 _AL_FREE(*config);
53810 *config = NULL;
53811 return;
53812 }
53813
53814 pos += ret;
53815
53816 p = (struct ZSCRIPT_CONFIG_ENTRY*)_AL_MALLOC(sizeof(ZSCRIPT_CONFIG_ENTRY));
53817 if (!p)
53818 {
53819 *allegro_errno = ENOMEM;
53820 _AL_FREE(*config);
53821 *config = NULL;
53822 return;
53823 }
53824
53825 p->name = name;
53826 p->data = val;
53827
53828 p->next = NULL;
53829 *prev = p;
53830 prev = &p->next;
53831 }
53832 }
53833
53834
53835
53836 /* zscript_load_config_file:
53837 * Does the work of loading a config file.
53838 */
53839 void zscript_load_config_file(ZSCRIPT_CONFIG **config, const char *filename, const char *savefile)
53840 {
53841 char *tmp, *tmp2;
53842 uint64_t length;
53843
53844 if (*config)
53845 {
53846 zscript_destroy_config(*config);
53847 *config = NULL;
53848 }
53849
53850 /* Special case when allegro_init has not been called yet. */
53851 if (!system_driver)
53852 {
53853 zscript_set_config(config, NULL, 0, savefile);
53854 return;
53855 }
53856
53857 length = file_size_ex(filename);
53858
53859 if (length > 0)
53860 {
53861 PACKFILE *f = pack_fopen(filename, F_READ);
53862
53863 if (f)
53864 {
53865 tmp = (char*)_AL_MALLOC_ATOMIC(length+1);
53866
53867 if (tmp)
53868 {
53869 pack_fread(tmp, length, f);
53870 tmp[length] = 0;
53871
53872 if (need_uconvert(tmp, U_UTF8, U_CURRENT))
53873 {
53874 length = uconvert_size(tmp, U_UTF8, U_CURRENT);
53875 tmp2 = (char*)_AL_MALLOC_ATOMIC(length);
53876
53877 if (tmp2)
53878 do_uconvert(tmp, U_UTF8, tmp2, U_CURRENT, length);
53879
53880 length -= ucwidth(0);
53881 }
53882 else
53883 tmp2 = tmp;
53884
53885 if (tmp2)
53886 {
53887 zscript_set_config(config, tmp2, length, savefile);
53888
53889 if (tmp2 != tmp)
53890 _AL_FREE(tmp2);
53891 }
53892
53893 _AL_FREE(tmp);
53894 }
53895 else
53896 zscript_set_config(config, NULL, 0, savefile);
53897
53898 pack_fclose(f);
53899 }
53900 else
53901 zscript_set_config(config, NULL, 0, savefile);
53902 }
53903 else
53904 zscript_set_config(config, NULL, 0, savefile);
53905 }
53906
53907
53908
53909 /* zscript_set_config_file:
53910 * Sets the file to be used for all future configuration operations.
53911 */
53912 void zscript_set_config_file(const char *filename)
53913 {
53914 ASSERT(filename);
53915 zscript_load_config_file(&config[0], filename, filename);
53916 }
53917
53918
53919
53920 /* zscript_set_config_data:
53921 * Sets the block of data to be used for all future configuration
53922 * operations.
53923 */
53924 void zscript_set_config_data(const char *data, int32_t length)
53925 {
53926 ASSERT(data);
53927 zscript_set_config(&config[0], data, length, NULL);
53928 }
53929
53930
53931
53932 /* zscript_override_config_file:
53933 * Sets the file that will override all future configuration operations.
53934 */
53935 void zscript_override_config_file(const char *filename)
53936 {
53937 /* load other configuration file to override settings */
53938 if (filename)
53939 zscript_load_config_file(&config_override, filename, filename);
53940 /* destroy the current one */
53941 else if (config_override)
53942 {
53943 zscript_destroy_config(config_override);
53944 config_override = NULL;
53945 }
53946 }
53947
53948
53949
53950 /* zscript_override_config_data:
53951 * Sets the block of data that will override all future configuration
53952 * operations.
53953 */
53954 void zscript_override_config_data(const char *data, int32_t length)
53955 {
53956 ASSERT(data);
53957 zscript_set_config(&config_override, data, length, NULL);
53958 }
53959
53960
53961
53962 /* zscript_push_config_state:
53963 * Pushes the current config state onto the stack.
53964 */
53965 void zscript_push_config_state(void)
53966 {
53967 int32_t i;
53968
53969 if (config[MAX_CONFIGS-1])
53970 zscript_destroy_config(config[MAX_CONFIGS-1]);
53971
53972 for (i=MAX_CONFIGS-1; i>0; i--)
53973 config[i] = config[i-1];
53974
53975 config[0] = NULL;
53976 }
53977
53978
53979
53980 /* zscript_pop_config_state:
53981 * Pops the current config state off the stack.
53982 */
53983 void zscript_pop_config_state(void)
53984 {
53985 int32_t i;
53986
53987 if (config[0])
53988 zscript_destroy_config(config[0]);
53989
53990 for (i=0; i<MAX_CONFIGS-1; i++)
53991 config[i] = config[i+1];
53992
53993 config[MAX_CONFIGS-1] = NULL;
53994 }
53995
53996
53997
53998 /* zscript_prettify_config_section_name:
53999 * Helper for ensuring that a section name is enclosed by [ ] braces.
54000 */
54001 void zscript_prettify_config_section_name(const char *in, char *out, int32_t out_size)
54002 {
54003 int32_t p;
54004
54005 if ((in) && (ustrlen(in)))
54006 {
54007 if (ugetc(in) != '[')
54008 {
54009 p = usetc(out, '[');
54010 usetc(out+p, 0);
54011 }
54012 else
54013 usetc(out, 0);
54014
54015 ustrzcat(out, out_size - ucwidth(']'), in);
54016
54017 out += uoffset(out, -1);
54018
54019 if (ugetc(out) != ']')
54020 {
54021 out += uwidth(out);
54022 out += usetc(out, ']');
54023 usetc(out, 0);
54024 }
54025 }
54026 else
54027 usetc(out, 0);
54028 }
54029
54030
54031
54032 /* zscript_hook_config_section:
54033 * Hooks a config section to a set of getter/setter functions. This will
54034 * override the normal table of values, and give the provider of the hooks
54035 * complete control over that section.
54036 */
54037 void zscript_hook_config_section(const char *section, int32_t (*intgetter)(const char *, int32_t), const char *(*stringgetter)(const char *, const char *), void (*stringsetter)(const char *, const char *))
54038 {
54039 ZSCRIPT_CONFIG_HOOK *hook, **prev;
54040 char section_name[256];
54041
54042 zscript_init_config(FALSE);
54043
54044 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
54045
54046 hook = config_hook;
54047 prev = &config_hook;
54048
54049 while (hook)
54050 {
54051 if (ustricmp(section_name, hook->section) == 0)
54052 {
54053 if ((intgetter) || (stringgetter) || (stringsetter))
54054 {
54055 /* modify existing hook */
54056 hook->intgetter = intgetter;
54057 hook->stringgetter = stringgetter;
54058 hook->stringsetter = stringsetter;
54059 }
54060 else
54061 {
54062 /* remove a hook */
54063 *prev = hook->next;
54064 _AL_FREE(hook->section);
54065 }
54066
54067 return;
54068 }
54069
54070 prev = &hook->next;
54071 hook = hook->next;
54072 }
54073
54074 /* add a new hook */
54075 hook = (struct ZSCRIPT_CONFIG_HOOK*)_AL_MALLOC(sizeof(ZSCRIPT_CONFIG_HOOK));
54076 if (!hook)
54077 return;
54078
54079 hook->section = _al_ustrdup(section_name);
54080 if (!(hook->section))
54081 {
54082 _AL_FREE(hook);
54083 return;
54084 }
54085
54086 hook->intgetter = intgetter;
54087 hook->stringgetter = stringgetter;
54088 hook->stringsetter = stringsetter;
54089
54090 hook->next = config_hook;
54091 config_hook = hook;
54092 }
54093
54094
54095
54096 /* is_config_hooked:
54097 * Checks whether a specific section is hooked in any way.
54098 */
54099 int32_t zscript_config_is_hooked(const char *section)
54100 {
54101 ZSCRIPT_CONFIG_HOOK *hook = config_hook;
54102 char section_name[256];
54103
54104 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
54105
54106 while (hook)
54107 {
54108 if (ustricmp(section_name, hook->section) == 0)
54109 return TRUE;
54110
54111 hook = hook->next;
54112 }
54113
54114 return FALSE;
54115 }
54116
54117
54118
54119 /* zscript_find_config_string:
54120 * Helper for finding an entry in the configuration file.
54121 */
54122 ZSCRIPT_CONFIG_ENTRY *zscript_find_config_string(ZSCRIPT_CONFIG *config, const char *section, const char *name, ZSCRIPT_CONFIG_ENTRY **prev)
54123 {
54124 ZSCRIPT_CONFIG_ENTRY *p;
54125 int32_t in_section;
54126
54127 if (config)
54128 {
54129 p = config->head;
54130
54131 if (prev)
54132 *prev = NULL;
54133
54134 if (section && ugetc(section))
54135 in_section = FALSE;
54136 else
54137 in_section = TRUE;
54138
54139 while (p)
54140 {
54141 if (p->name)
54142 {
54143 if ((section) && (ugetc(p->name) == '[') && (ugetat(p->name, -1) == ']'))
54144 {
54145 /* change section */
54146 in_section = (ustricmp(section, p->name) == 0);
54147 }
54148 if ((in_section) || (ugetc(name) == '['))
54149 {
54150 /* is this the one? */
54151 if (ustricmp(p->name, name) == 0)
54152 return p;
54153 }
54154 }
54155
54156 if (prev)
54157 *prev = p;
54158
54159 p = p->next;
54160 }
54161 }
54162
54163 return NULL;
54164 }
54165
54166
54167
54168 /* zscript_get_config_string:
54169 * Reads a string from the configuration file.
54170 */
54171 const char *zscript_get_config_string(const char *section, const char *name, const char *def)
54172 {
54173 char section_name[256];
54174 ZSCRIPT_CONFIG_HOOK *hook;
54175 ZSCRIPT_CONFIG_ENTRY *p;
54176
54177 zscript_init_config(TRUE);
54178
54179 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
54180
54181 /* check for hooked sections */
54182 hook = config_hook;
54183
54184 while (hook)
54185 {
54186 if (ustricmp(section_name, hook->section) == 0)
54187 {
54188 if (hook->stringgetter)
54189 return hook->stringgetter(name, def);
54190 else
54191 return def;
54192 }
54193 hook = hook->next;
54194 }
54195
54196 /* find the string */
54197 p = zscript_find_config_string(config_override, section_name, name, NULL);
54198
54199 if (!p)
54200 {
54201 if ((ugetc(name) == '#') || ((ugetc(section_name) == '[') && (ugetat(section_name, 1) == '#')))
54202 p = zscript_find_config_string(system_config, section_name, name, NULL);
54203 else
54204 p = zscript_find_config_string(config[0], section_name, name, NULL);
54205 }
54206
54207 if (p && p->data && (ustrlen(p->data) != 0))
54208 return p->data;
54209 else
54210 return def;
54211 }
54212
54213
54214
54215 /* zscript_get_config_int:
54216 * Reads an integer from the configuration file.
54217 */
54218 int32_t zscript_get_config_int(const char *section, const char *name, int32_t def)
54219 {
54220 ZSCRIPT_CONFIG_HOOK *hook;
54221 char section_name[256];
54222 const char *s;
54223
54224 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
54225
54226 /* check for hooked sections */
54227 hook = config_hook;
54228
54229 while (hook)
54230 {
54231 if (ustricmp(section_name, hook->section) == 0)
54232 {
54233 if (hook->intgetter)
54234 {
54235 return hook->intgetter(name, def);
54236 }
54237 else if (hook->stringgetter)
54238 {
54239 s = hook->stringgetter(name, NULL);
54240 if ((s) && (ugetc(s)))
54241 return ustrtol(s, NULL, 0);
54242 else
54243 return def;
54244 }
54245 else
54246 return def;
54247 }
54248 hook = hook->next;
54249 }
54250
54251 /* read normal data */
54252 s = zscript_get_config_string(section_name, name, NULL);
54253
54254 if ((s) && (ugetc(s)))
54255 return ustrtol(s, NULL, 0);
54256
54257 return def;
54258 }
54259
54260
54261
54262 /* zscript_get_config_hex:
54263 * Reads a hexadecimal integer from the configuration file.
54264 */
54265 int32_t zscript_get_config_hex(const char *section, const char *name, int32_t def)
54266 {
54267 const char *s = zscript_get_config_string(section, name, NULL);
54268 char tmp[64];
54269 int32_t i;
54270
54271 if ((s) && (ugetc(s)))
54272 {
54273 i = ustrtol(s, NULL, 16);
54274 if ((i == 0x7FFFFFFF) && (ustricmp(s, uconvert_ascii("7FFFFFFF", tmp)) != 0))
54275 i = -1;
54276 return i;
54277 }
54278
54279 return def;
54280 }
54281
54282
54283
54284 /* zscript_get_config_float:
54285 * Reads a float from the configuration file.
54286 */
54287 float zscript_get_config_float(const char *section, const char *name, float def)
54288 {
54289 const char* s = zscript_get_config_string(section, name, NULL);
54290
54291 if ((s) && (ugetc(s)))
54292 return uatof(s);
54293
54294 return def;
54295 }
54296
54297
54298
54299 /* zscript_get_config_id:
54300 * Reads a driver ID number from the configuration file.
54301 */
54302 int32_t zscript_get_config_id(const char *section, const char *name, int32_t def)
54303 {
54304 const char *s = zscript_get_config_string(section, name, NULL);
54305 char tmp[4];
54306 char* endp;
54307 int32_t val, i;
54308
54309 if ((s) && (ugetc(s)))
54310 {
54311 val = ustrtol(s, &endp, 0);
54312 if (!ugetc(endp))
54313 return val;
54314
54315 tmp[0] = tmp[1] = tmp[2] = tmp[3] = ' ';
54316
54317 for (i=0; i<4; i++)
54318 {
54319 if (ugetat(s, i))
54320 tmp[i] = utoupper(ugetat(s ,i));
54321 else
54322 break;
54323 }
54324
54325 return AL_ID(tmp[0], tmp[1], tmp[2], tmp[3]);
54326 }
54327
54328 return def;
54329 }
54330
54331
54332
54333 /* zscript_get_config_argv:
54334 * Reads an argc/argv style token list from the configuration file.
54335 */
54336 char **zscript_get_config_argv(const char *section, const char *name, int32_t *argc)
54337 {
54338 int32_t pos, ac, q, c;
54339 int32_t s_size;
54340 int32_t i;
54341
54342 const char *s = zscript_get_config_string(section, name, NULL);
54343
54344 if (!s)
54345 {
54346 *argc = 0;
54347 return NULL;
54348 }
54349
54350 /* clean up the old argv that was allocated the last time this function was
54351 * called.
54352 */
54353 _AL_FREE(config_argv);
54354 config_argv = NULL;
54355
54356 /* increase the buffer size if needed */
54357 s_size = ustrsizez(s);
54358 if (s_size>argv_buf_size)
54359 {
54360 argv_buf_size = s_size;
54361 argv_buf = (char*)_al_sane_realloc(argv_buf, argv_buf_size);
54362 if (!argv_buf)
54363 {
54364 *allegro_errno = ENOMEM;
54365 *argc = 0;
54366 return NULL;
54367 }
54368 }
54369
54370 ustrzcpy(argv_buf, argv_buf_size, s);
54371 pos = 0;
54372 ac = 0;
54373
54374 /* tokenize the buffer and count the number of words; every space character
54375 * as well as single and double quotes are replaced with zeros; comments * that start with # are also cut off with a 0
54376 */
54377 c = ugetc(argv_buf);
54378 while ((c) && (c != '#'))
54379 {
54380 /* replace all spaces up to the next word with 0 */
54381 while ((c) && (uisspace(c)))
54382 {
54383 usetat(argv_buf+pos, 0, 0);
54384 pos += ucwidth(0);
54385 c = ugetc(argv_buf+pos);
54386 }
54387
54388 /* quit if we reached the end of the buffer or a comment */
54389 if ((c) && (c != '#'))
54390 {
54391 /* found another word! */
54392 ac++;
54393
54394 /* cut away quotes by replacing them with 0 */
54395 if ((c == '\'') || (c == '"'))
54396 {
54397 q = c;
54398 usetat(argv_buf+pos, 0, 0);
54399 pos += ucwidth(0);
54400 c = ugetc(argv_buf+pos);
54401 }
54402 else
54403 {
54404 q = 0;
54405 }
54406
54407 /* search for the end of the word */
54408 while ((c) && ((q) ? (c != q) : (!uisspace(c))))
54409 {
54410 pos += ucwidth(c);
54411 c = ugetc(argv_buf+pos);
54412 }
54413 }
54414 }
54415
54416 /* now that we know how many words there are in the buffer, allocate enough
54417 * space for a list of pointers to them, or return 0 if there are no words
54418 */
54419 if (ac > 0)
54420 {
54421 config_argv = (char**)_AL_MALLOC(ac*sizeof *config_argv);
54422 }
54423 else
54424 {
54425 *argc = 0;
54426 return NULL;
54427 }
54428
54429 /* go through the tokenized buffer and assign pointers in argv to point to
54430 * the beginning of each individual word
54431 */
54432 for (i=0,pos=0,c=ugetc(argv_buf); i<ac; i++)
54433 {
54434 /* find next word */
54435 while (!c)
54436 {
54437 pos += ucwidth(c);
54438 c = ugetc(argv_buf+pos);
54439 }
54440
54441 /* assign pointer */
54442 config_argv[i] = argv_buf+pos;
54443
54444 /* find end of the word */
54445 while (c)
54446 {
54447 pos += ucwidth(c);
54448 c = ugetc(argv_buf+pos);
54449 }
54450 }
54451
54452 *argc = ac;
54453 return config_argv;
54454 }
54455
54456
54457
54458 /* zscript_insert_config_variable:
54459 * Helper for inserting a new variable into a configuration file.
54460 */
54461 ZSCRIPT_CONFIG_ENTRY *zscript_insert_config_variable(ZSCRIPT_CONFIG *the_config, ZSCRIPT_CONFIG_ENTRY *p, const char *name, const char *data)
54462 {
54463 ZSCRIPT_CONFIG_ENTRY *n = (struct ZSCRIPT_CONFIG_ENTRY*)_AL_MALLOC(sizeof(ZSCRIPT_CONFIG_ENTRY));
54464
54465 if (!n)
54466 return NULL;
54467
54468 if (name)
54469 n->name = _al_ustrdup(name);
54470 else
54471 n->name = NULL;
54472
54473 if (data)
54474 n->data = _al_ustrdup(data);
54475 else
54476 n->data = NULL;
54477
54478 if (p)
54479 {
54480 n->next = p->next;
54481 p->next = n;
54482 }
54483 else
54484 {
54485 n->next = NULL;
54486 the_config->head = n;
54487 }
54488
54489 return n;
54490 }
54491
54492
54493
54494 /* zscript_set_config_string:
54495 * Writes a string to the configuration file.
54496 */
54497 void zscript_set_config_string(const char *section, const char *name, const char *val)
54498 {
54499 ZSCRIPT_CONFIG *the_config;
54500 ZSCRIPT_CONFIG_HOOK *hook;
54501 ZSCRIPT_CONFIG_ENTRY *p, *prev;
54502 char section_name[256];
54503
54504 zscript_init_config(TRUE);
54505
54506 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
54507
54508 /* check for hooked sections */
54509 hook = config_hook;
54510
54511 while (hook)
54512 {
54513 if (ustricmp(section_name, hook->section) == 0)
54514 {
54515 if (hook->stringsetter)
54516 hook->stringsetter(name, val);
54517 return;
54518 }
54519 hook = hook->next;
54520 }
54521
54522 /* decide which config file to use */
54523 if ((ugetc(name) == '#') || ((ugetc(section_name) == '[') && (ugetat(section_name, 1) == '#')))
54524 the_config = system_config;
54525 else if (config_override)
54526 the_config = config_override;
54527 else
54528 the_config = config[0];
54529
54530 if (the_config)
54531 {
54532 p = zscript_find_config_string(the_config, section_name, name, &prev);
54533
54534 if (p)
54535 {
54536 if ((val) && (ugetc(val)))
54537 {
54538 /* modify existing variable */
54539 if (p->data)
54540 _AL_FREE(p->data);
54541
54542 p->data = _al_ustrdup(val);
54543 }
54544 else
54545 {
54546 /* delete variable */
54547 if (p->name)
54548 _AL_FREE(p->name);
54549
54550 if (p->data)
54551 _AL_FREE(p->data);
54552
54553 if (prev)
54554 prev->next = p->next;
54555 else
54556 the_config->head = p->next;
54557
54558 _AL_FREE(p);
54559 }
54560 }
54561 else
54562 {
54563 if ((val) && (ugetc(val)))
54564 {
54565 /* add a new variable */
54566 if (ugetc(section_name))
54567 {
54568 p = zscript_find_config_string(the_config, NULL, section_name, &prev);
54569
54570 if (!p)
54571 {
54572 /* create a new section */
54573 p = the_config->head;
54574 while ((p) && (p->next))
54575 p = p->next;
54576
54577 if ((p) && (p->data) && (ugetc(p->data)))
54578 p = zscript_insert_config_variable(the_config, p, NULL, NULL);
54579
54580 p = zscript_insert_config_variable(the_config, p, section_name, NULL);
54581 }
54582
54583 /* append to the end of the section */
54584 while ((p) && (p->next) &&
54585 (((p->next->name) && (ugetc(p->next->name))) ||
54586 ((p->next->data) && (ugetc(p->next->data)))))
54587 {
54588 p = p->next;
54589 }
54590
54591 p = zscript_insert_config_variable(the_config, p, name, val);
54592 }
54593 else
54594 {
54595 /* global variable */
54596 p = the_config->head;
54597 zscript_insert_config_variable(the_config, NULL, name, val);
54598 the_config->head->next = p;
54599 }
54600 }
54601 }
54602
54603 the_config->dirty = TRUE;
54604 }
54605 }
54606
54607
54608
54609 /* zscript_set_config_int:
54610 * Writes an integer to the configuration file.
54611 */
54612 void zscript_set_config_int(const char *section, const char *name, int32_t val)
54613 {
54614 char buf[32], tmp[32];
54615 uszprintf(buf, sizeof(buf), uconvert_ascii("%d", tmp), val);
54616 zscript_set_config_string(section, name, buf);
54617 }
54618
54619
54620
54621 /* zscript_set_config_hex:
54622 * Writes a hexadecimal integer to the configuration file.
54623 */
54624 void zscript_set_config_hex(const char *section, const char *name, int32_t val)
54625 {
54626 char buf[32], tmp[32];
54627
54628 if (val >= 0)
54629 {
54630 uszprintf(buf, sizeof(buf), uconvert_ascii("%X", tmp), val);
54631 zscript_set_config_string(section, name, buf);
54632 }
54633 else
54634 zscript_set_config_string(section, name, uconvert_ascii("-1", buf));
54635 }
54636
54637
54638
54639 /* zscript_set_config_float:
54640 * Writes a float to the configuration file.
54641 */
54642 void zscript_set_config_float(const char *section, const char *name, float val)
54643 {
54644 char buf[32], tmp[32];
54645 uszprintf(buf, sizeof(buf), uconvert_ascii("%f", tmp), val);
54646 zscript_set_config_string(section, name, buf);
54647 }
54648
54649
54650
54651 /* zscript_set_config_id:
54652 * Writes a driver ID to the configuration file.
54653 */
54654 void zscript_set_config_id(const char *section, const char *name, int32_t val)
54655 {
54656 char buf[32], tmp[32];
54657 int32_t v[4];
54658 int32_t pos = 0;
54659 int32_t i;
54660
54661 if (val < 256)
54662 {
54663 uszprintf(buf, sizeof(buf), uconvert_ascii("%d", tmp), val);
54664 }
54665 else
54666 {
54667 v[0] = (val>>24)&0xFF;
54668 v[1] = (val>>16)&0xFF;
54669 v[2] = (val>>8)&0xFF;
54670 v[3] = val&0xFF;
54671
54672 for (i=0; (i<4) && (v[i]) && (v[i] != ' '); i++)
54673 pos += usetc(buf+pos, v[i]);
54674
54675 usetc(buf+pos, 0);
54676 }
54677
54678 zscript_set_config_string(section, name, buf);
54679 }
54680
54681
54682
54683 /* _zscript_reload_config:
54684 * Internal helper to reload the configuration from allegro_init, in case
54685 * zscript_set_config_file was called before allegro_init.
54686 */
54687 void _zscript_reload_config(void)
54688 {
54689 if (config[0])
54690 {
54691 char *name = _al_ustrdup(config[0]->filename);
54692 zscript_set_config_file(name);
54693 _AL_FREE(name);
54694 }
54695 }
54696
54697
54698
54699 /* zscript_reload_config_texts:
54700 * Reads in a block of translated system text, looking for either a
54701 * user-specified file, a ??text.cfg file, or a language.dat#??TEXT_CFG
54702 * datafile object. If new_language is not NULL, the language config
54703 * variable will be set to new_language before reloading the
54704 * configuration files.
54705 */
54706 void zscript_reload_config_texts(const char *new_language)
54707 {
54708 char filename[1024], tmp1[128], tmp2[128];
54709 const char *name, *ext, *datafile;
54710 char *namecpy;
54711
54712 if (config_language)
54713 {
54714 zscript_destroy_config(config_language);
54715 config_language = NULL;
54716 }
54717
54718 if (new_language)
54719 zscript_set_config_string("system", "language", new_language);
54720
54721 name = zscript_get_config_string(uconvert_ascii("system", tmp1), uconvert_ascii("language", tmp2), NULL);
54722
54723 if ((name) && (ugetc(name)))
54724 {
54725 namecpy = _al_ustrdup(name);
54726 ustrlwr (namecpy);
54727 if ((ustrlen(namecpy)<4) || (ustricmp(namecpy+uoffset(namecpy, -4), uconvert_ascii("text", tmp1)) != 0))
54728 ext = uconvert_ascii("text.cfg", tmp1);
54729 else
54730 ext = uconvert_ascii(".cfg", tmp1);
54731
54732 datafile = uconvert_ascii("language.dat", tmp2);
54733
54734 if (find_allegro_resource(filename, namecpy, ext, datafile, NULL, NULL, NULL, sizeof(filename)) == 0)
54735 {
54736 _AL_FREE(namecpy);
54737 zscript_load_config_file(&config_language, filename, NULL);
54738 return;
54739 }
54740
54741 _AL_FREE(namecpy);
54742 }
54743
54744 config_language = (struct ZSCRIPT_CONFIG*)_AL_MALLOC(sizeof(ZSCRIPT_CONFIG));
54745 if (config_language )
54746 {
54747 config_language ->head = NULL;
54748 config_language ->filename = NULL;
54749 config_language ->dirty = FALSE;
54750 }
54751 }
54752
54753
54754
54755 /* zscript_get_config_text:
54756 * Looks up a translated version of the specified English string,
54757 * returning a suitable message in the current language if one is
54758 * available, or a copy of the parameter if no translation can be found.
54759 */
54760 const char *zscript_get_config_text(const char *msg)
54761 {
54762 char tmp1[256];
54763 const char *section;
54764 const char *umsg;
54765 const char *s;
54766 const char *ret = NULL;
54767 char *name;
54768 ZSCRIPT_CONFIG_HOOK *hook;
54769 ZSCRIPT_CONFIG_ENTRY *p;
54770 int32_t c, pos, size;
54771 ASSERT(msg);
54772
54773 /* Hack: the inline definition of install_allegro() from 4.2.0 calls
54774 * zscript_get_config_text() even before Allegro has been initialised, leading
54775 * to a crash in get_executable_name(). To retain binary compatibility
54776 * we check for this case.
54777 */
54778 if (_allegro_count == 0)
54779 {
54780 return msg;
54781 }
54782
54783 zscript_init_config(TRUE);
54784
54785 section = uconvert_ascii("[language]", tmp1);
54786
54787 /* allocate memory and convert message to current encoding format */
54788 if (need_uconvert(msg, U_ASCII, U_CURRENT))
54789 {
54790 size = uconvert_size(msg, U_ASCII, U_CURRENT);
54791 umsg = (char*)_AL_MALLOC_ATOMIC(size);
54792 if (!umsg)
54793 {
54794 *allegro_errno = ENOMEM;
54795 return empty_string;
54796 }
54797
54798 name = (char*)_AL_MALLOC_ATOMIC(size);
54799 if (!name)
54800 {
54801 _AL_FREE((char *)umsg); /* remove constness */
54802 *allegro_errno = ENOMEM;
54803 return empty_string;
54804 }
54805
54806 do_uconvert(msg, U_ASCII, (char*)umsg, U_CURRENT, size);
54807 }
54808 else
54809 {
54810 umsg = msg;
54811 name = (char*)_AL_MALLOC_ATOMIC(ustrsizez(msg));
54812 if (!name)
54813 {
54814 *allegro_errno = ENOMEM;
54815 return empty_string;
54816 }
54817 }
54818
54819 s = umsg;
54820 pos = 0;
54821
54822 while ((c = ugetxc(&s)) != 0)
54823 {
54824 if ((uisspace(c)) || (c == '=') || (c == '#'))
54825 pos += usetc(name+pos, '_');
54826 else
54827 pos += usetc(name+pos, c);
54828 }
54829
54830 usetc(name+pos, 0);
54831
54832 /* check for hooked sections */
54833 hook = config_hook;
54834
54835 while (hook)
54836 {
54837 if (ustricmp(section, hook->section) == 0)
54838 {
54839 if (hook->stringgetter)
54840 {
54841 ret = hook->stringgetter(name, umsg);
54842 break;
54843 }
54844 }
54845
54846 hook = hook->next;
54847 }
54848
54849 if (!ret)
54850 {
54851 /* find the string */
54852 p = zscript_find_config_string(config_override, section, name, NULL);
54853
54854 if (!p)
54855 {
54856 p = zscript_find_config_string(config[0], section, name, NULL);
54857
54858 if (!p)
54859 p = zscript_find_config_string(config_language, section, name, NULL);
54860 }
54861
54862 if (p)
54863 {
54864 ret = (p->data ? p->data : empty_string);
54865 }
54866 else
54867 {
54868 /* no translation, so store off this value in the file */
54869 p = config_language->head;
54870 zscript_insert_config_variable(config_language, NULL, name, umsg);
54871 config_language->head->next = p;
54872 ret = config_language->head->data;
54873 }
54874 }
54875
54876 /* free memory */
54877 if (umsg!=msg)
54878 _AL_FREE((char*) umsg); /* remove constness */
54879
54880 _AL_FREE(name);
54881
54882 return ret;
54883 }
54884
54885
54886
54887 /* zscript_add_unique_config_name
54888 * Helper to add a name to a list of names.
54889 */
54890 int32_t zscript_add_unique_config_name(const char ***names, int32_t n, char const *name)
54891 {
54892 int32_t i;
54893 /* FIXME: use better search algorithm */
54894 for (i = 0; i < n; i++)
54895 if (!ustrcmp((*names)[i], name))
54896 return n;
54897
54898 *names = (const char**)_al_sane_realloc((void *)*names, (n + 1) * sizeof **names);
54899 (*names)[n] = name;
54900 return n + 1;
54901 }
54902
54903
54904
54905 /* zscript_attach_config_entries
54906 * Helper function to attach key or section names to a list of strings.
54907 */
54908 int32_t zscript_attach_config_entries(ZSCRIPT_CONFIG *conf, const char *section, int32_t n, const char ***names, int32_t list_sections)
54909 {
54910 ZSCRIPT_CONFIG_ENTRY *p;
54911 char section_name[256];
54912 int32_t in_section;
54913
54914 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
54915
54916 if (conf)
54917 {
54918 p = conf->head;
54919
54920 /* If section is NULL, only initial, section-less entries are used. */
54921 if (ugetc(section_name))
54922 in_section = FALSE;
54923 else
54924 in_section = TRUE;
54925
54926 while (p)
54927 {
54928 if (p->name)
54929 {
54930 /* a section start is just a list entry enclosed in [] */
54931 if (ugetc(p->name) == '[' && ugetat(p->name, -1) == ']')
54932 {
54933 if (list_sections)
54934 {
54935 n = zscript_add_unique_config_name(names, n, p->name);
54936 }
54937 in_section = (ustricmp(section_name, p->name) == 0);
54938 }
54939 else if (in_section && !list_sections)
54940 {
54941 n = zscript_add_unique_config_name(names, n, p->name);
54942 }
54943 }
54944 p = p->next;
54945 }
54946 }
54947 return n;
54948 }
54949
54950
54951
54952 /* list_config_entires:
54953 * Returns the names of all config entries in a section. The names parameter is
54954 * a pointer to a strings array that will contain the config keys. If it points to
54955 * a NULL pointer, it will be allocated, or else re-allocated accordingly. The
54956 * return value tells how many valid string pointers it contains after the
54957 * function returns.
54958 */
54959 int32_t zscript_list_config_entries(const char *section, const char ***names)
54960 {
54961 int32_t n = 0;
54962 n = zscript_attach_config_entries(config_override, section, n, names, 0);
54963 n = zscript_attach_config_entries(config[0], section, n, names, 0);
54964 return n;
54965 }
54966
54967
54968
54969 /* zscript_list_config_sections:
54970 * Returns the names of all current config sections, enclodes in []. The names
54971 * parameter and return value is like in list_config_entires above.
54972 */
54973 int32_t zscript_list_config_sections(const char ***names)
54974 {
54975 int32_t n = 0;
54976 n = zscript_attach_config_entries(config_override, NULL, n, names, 1);
54977 n = zscript_attach_config_entries(config[0], NULL, n, names, 1);
54978 return n;
54979 }
54980
54981
54982
54983 /* zscript_free_config_entries:
54984 * Frees the entries list returned by list_config_entires or
54985 * zscript_list_config_sections again.
54986 */
54987 void zscript_free_config_entries(const char ***names)
54988 {
54989 _AL_FREE(*names);
54990 *names = NULL;
54991 }
54992
54993 225833 int32_t FFScript::Distance(double x1, double y1, double x2, double y2)
54994 {
54995 225833 double x = (x1-x2);
54996 225833 double y = (y1-y2);
54997 225833 double sum = (x*x)+(y*y);
54998 //if(((int32_t)sum) < 0)
54999 //{
55000 // Z_scripterrlog("Distance() attempted to calculate square root of %ld!\n", ((int32_t)sum));
55001 // return -10000;;
55002 //}
55003 225833 sum *= 1000000.0;
55004 225833 double total = sqrt(sum)*10;
55005 225833 return int32_t(total);
55006 }
55007
55008 int32_t FFScript::Distance(double x1, double y1, double x2, double y2, int32_t scale)
55009 {
55010 double x3 = x1+(x2-x1)/scale;
55011 double y3 = y1+(y2-y1)/scale;
55012 //double sum = (x*x)+(y*y);
55013 //if(((int32_t)sum) < 0)
55014 //{
55015 // Z_scripterrlog("Distance() attempted to calculate square root of %ld!\n", ((int32_t)sum));
55016 // return -10000;
55017 //}
55018 //sum *= 1000000.0;
55019 //double total = sqrt(sum)*10;
55020 //return int32_t(total*scale);
55021 return (FFCore.Distance(x1, y1, x3, y3)*scale);
55022 }
55023
55024 int32_t FFScript::LongDistance(double x1, double y1, double x2, double y2)
55025 {
55026 double x = (x1-x2);
55027 double y = (y1-y2);
55028 double sum = (x*x)+(y*y);
55029 //if(((int32_t)sum) < 0)
55030 //{
55031 // Z_scripterrlog("Distance() attempted to calculate square root of %ld!\n", ((int32_t)sum));
55032 // return -10000;;
55033 //}
55034 double total = sqrt(sum);
55035 return int32_t(total);
55036 }
55037
55038 int32_t FFScript::LongDistance(double x1, double y1, double x2, double y2, int32_t scale)
55039 {
55040 double x3 = x1+(x2-x1)/scale;
55041 double y3 = y1+(y2-y1)/scale;
55042 //double sum = (x*x)+(y*y);
55043 //if(((int32_t)sum) < 0)
55044 //{
55045 // Z_scripterrlog("Distance() attempted to calculate square root of %ld!\n", ((int32_t)sum));
55046 // return -10000;
55047 //}
55048 //sum *= 1000000.0;
55049 //double total = sqrt(sum)*10;
55050 //return int32_t(total*scale);
55051 return (FFCore.LongDistance(x1, y1, x3, y3)*scale);
55052 }
55053
55054 void FFScript::do_distance()
55055 {
55056 double x1 = double(ri->d[rSFTEMP] / 10000.0);
55057 double x2 = double(ri->d[rINDEX] / 10000.0);
55058 double y1 = double(ri->d[rINDEX2] / 10000.0);
55059 double y2 = double(ri->d[rEXP1] / 10000.0);
55060
55061 int32_t result = FFCore.Distance(x1, x2, y1, y2);
55062 //ret = result*10000;
55063
55064 }
55065
55066 42290211 bool command_is_wait(int command)
55067 {
55068
2/2
✓ Branch 0 taken 42284663 times.
✓ Branch 1 taken 5548 times.
42290211 switch (command)
55069 {
55070 case WAITFRAME:
55071 case WAITDRAW:
55072 case WAITTO:
55073 case WAITEVENT:
55074 case WAITFRAMESR:
55075 5548 return true;
55076 }
55077 42284663 return false;
55078 42290211 }
55079
55080 42288576 bool command_uses_comparison_result(int command)
55081 {
55082
2/2
✓ Branch 0 taken 1164646 times.
✓ Branch 1 taken 41123930 times.
42288576 switch (command)
55083 {
55084 case GOTOTRUE:
55085 case GOTOFALSE:
55086 case GOTOMORE:
55087 case GOTOLESS:
55088 case SETTRUE:
55089 case SETTRUEI:
55090 case SETFALSE:
55091 case SETFALSEI:
55092 case SETMOREI:
55093 case SETLESSI:
55094 case SETMORE:
55095 case SETLESS:
55096 1164646 return true;
55097 }
55098 41123930 return false;
55099 42288576 }
55100
55101 495796 bool command_could_return_not_ok(int command)
55102 {
55103
2/2
✓ Branch 0 taken 1707 times.
✓ Branch 1 taken 494089 times.
495796 switch (command)
55104 {
55105 case 0xFFFF:
55106 case EWPNDEL:
55107 case GAMECONTINUE:
55108 case GAMEEND:
55109 case GAMERELOAD:
55110 case GAMESAVECONTINUE:
55111 case GAMESAVEQUIT:
55112 case ITEMDEL:
55113 case LWPNDEL:
55114 case NPCKICKBUCKET:
55115 case SETSCREENDOOR:
55116 case SETSCREENENEMY:
55117 1707 return true;
55118 }
55119 494089 return false;
55120 495796 }
55121
55122 const script_command& get_script_command(int command)
55123 {
55124 return ZASMcommands[command];
55125 }
55126
55127 99088452 int32_t get_combopos_ref(int32_t pos, int32_t layer)
55128 {
55129 99088452 return layer * 176 + pos;
55130 }
55131
55132 94370 int32_t combopos_ref_to_pos(int32_t combopos_ref)
55133 {
55134 94370 return combopos_ref % 176;
55135 }
55136
55137 38089 int32_t combopos_ref_to_layer(int32_t combopos_ref)
55138 {
55139 38089 return combopos_ref / 176;
55140 }
55141
55142